Mac OS下安装homebrew
运行命令
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
选择中科大镜像速度较快
通过Homebrew安装sshpass
创建 sshpass.rb
文件
创建 sshpass.rb
文件,文件内容为:
require 'formula'
class Sshpass < Formula
url 'http://sourceforge.net/projects/sshpass/files/sshpass/1.06/sshpass-1.06.tar.gz'
homepage 'http://sourceforge.net/projects/sshpass'
sha256 'c6324fcee608b99a58f9870157dfa754837f8c48be3df0f5e2f3accf145dee60'
def install
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make install"
end
def test
system "sshpass"
end
end
安装
在文件所在目录下执行安装命令
brew install sshpass.rb
创建alias命令并永久保持
如果当前终端使用的是bash,则编辑 .bashrc
,如果当前终端使用的是zsh,则编辑 .zshrc
。
编辑终端对应的文件
以下以zsh为例
在 ~
路径下编辑 .zshrc
,增加要使用的alias
alias ll='ls -l'
保存并退出,执行
source ~/.zshrc
此时即可使用 ll
命令,但当终端退出重启后 ll
命令将失效。应当再编辑 .bash_profile
,如果不存在 .bash_profile
文件则通过 touch .bash_profile
创建。
在终端启动会话时会自动执行 .bash_profile
,故此时仅需在 .bash_profile
下添加一行 source
命令即可。
source ~/.zshrc
添加完成后重启终端,ll
命令可以正常使用。