macで開発してとgitコマンドをtabで入力補完してくれ他のでイライラしたので、入力補完をいれてみました(今更)。まぁ、Homebrew経由でインストールすればこんなことにならないのでちゃんとやりましょう。
僕の場合はgitが以下のインストーラーで、bash-completionがHomebrewで入れたのでちょっとめんどくさいことになったのでその備忘録として。だから参考にしないでください。
Git
bash-completionのインストール
brew install bash-completion
「/usr/local/etc/bash_completion.d/」にコマンド補完用のシンボリックリンクが出来ていると思います。僕の場合はgit-completion.bashとかが入ってますが気にしないでください。
bash_completion.dに以下を書く
if [ -f $(brew --prefix)/etc/bash_completion ]; then
source $(brew --prefix)/etc/bash_completion
fi
gitをHomebrewでインストールしてないのでgit-completion.bashとgit-prompt.shがありません。
なのでwgetで入れます(そもそもwgetすらない)。
brew install wget cd /usr/local/etc/bash_completion.d/ wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -O git-completion.bash wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O git-prompt.sh
で
cd source .bash_profile
でgit statusって打とうとしてタブ入力したら以下のエラー
git staUnknown option: --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config usage: git [--version] [--help] [-C <path>] [-c name=value] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p | --paginate | --no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] <command> [<args>]
これは2.18から「--list-cmds」が追加されたようで、git-completion.bashは2.18、gitは2.16.3だったのでgitでオプションがないよ!って言われてるみたい
git-completion.bashのバージョンを下げるかgitをあげるかどちらかなんですが、下げる意味がないので私はバージョンをあげて対処しました。Homebrewでインストールしてないのでここでインストーラーから入れました。
まじで誰も得しない記事だなこれは!