##安装bash-completion
-
用homebrew安装
bash-completion软件包:brew install bash-completion -
把下面内容添加到你的
~/.bash_profile:1if [ -f $(brew --prefix)/etc/bash_completion ]; then 2 . $(brew --prefix)/etc/bash_completion 3fi -
重启bash,看看是不是很多命令都可以通过tab自动补全了?
##添加其它自动补全支持
有些命令的自动补全支持不在bash-completion内,这时候可以手动添加进去,以git为例:
1cd /usr/local/opt/bash-completion/etc/bash_completion.d 2curl -L -O https://raw.github.com/git/git/master/contrib/completion/git-completion.bash 3brew unlink bash-completion 4brew link bash-completion
现在试试看,git 命令是不是已经可以自动补全了?
其它常用命令自动补全文件: