关注IT
关注系统玩家

MAC 下为应用添加TAB补全功能

这些并非原创,只是用到了做个总结,记录一下。

安装bash-completion

在为其他软件配置之前,我们先配置bash-completion,安装bash-completion需要用到brew,如果没有安装可以执行以下命令安装:
/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)” (这里是英文引号)
参考链接:https://brew.sh/index_zh-cn.html

安装bash-completion:

brew install bash-completion
执行:brew info  bash-completion  得到以下内容:
hongxiaoludeMacBook-Pro:~ hongxiaolu$ brew info  bash-completion
bash-completion: stable 1.3 (bottled)
Programmable completion for Bash 3.2
https://bash-completion.alioth.debian.org/
Conflicts with:
bash-completion@2 (because Differing version of same formula)
/usr/local/Cellar/bash-completion/1.3_3 (189 files, 608.2KB) *
Poured from bottle on 2017-10-24 at 22:37:05
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/bash-completion.rb
==> Caveats
Add the following line to your ~/.bash_profile:
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
我们把 [ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion 放进 ~/.bash_profile

为MAC 添加 ll 命令

编辑~/.bash_profile 文件,放入:alias ‘ll=ls -lAF’

为git 增加TAB 补全

curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o /usr/local/etc/bash_completion.d/git-completion.bash-completion

为Docker 增加TAB补全

因为MAC上安装了DOCKER,所以其实已经有completion文件:
cd /usr/local/etc/bash_completion.d
ln -s /Applications/Docker.app/Contents/Resources/etc/docker.bash-completion
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.bash-completion
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion

问题检查

如果配置过程中出现bash: 404:: command not found 错误,可以通过命令:
bash -lxe
显示结果中,搜索bash: 404:: command not found  很容易定位到出问题的命令。

分享到:更多 ()
喜欢 0
rancher

评论 抢沙发

评论前必须登录!