done is better than perfect

自分が学んだことや、作成したプログラムの記事を書きます。すべての記載は他に定める場合を除き個人的なものです。

MacにHomebrewでbash-completionを入れた

bashをもう少し効率的に使いたくなったので、bash-completionを入れてみました。 以下、その手順についてメモ。
インストール
Homebrewを使って入れます。
$ brew install bash-completion
設定
~/.bashrcに以下のように記述します。
if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion
fi
これだけで、bash-completionは動くようになっているはずです。 動かすためには、source ~/.bashrcなどで設定を読み込み直すのを忘れずに!
動作
実際に動かしてみます。
$ git [TAB]
add                      config                   instaweb                  reset
am                       credential               log                       revert
annotate                 credential-osxkeychain   merge                     rm
apply                    describe                   mergetool                send-email
archive                  diff                     mv                        shortlog
bisect                   difftool                 name-rev                  show
blame                    fetch                    notes                     show-branch
branch                   filter-branch            p4                        stage
bundle                   format-patch             pull                      stash
checkout                 fsck                     push                      status
cherry                   gc                       rebase                    submodule
cherry-pick              get-tar-commit-id        reflog                    subtree
citool                   grep                     relink                    svn
clean                    gui                      remote                    tag
clone                    help                     repack                    whatchanged
column                   imap-send                replace
commit                   init                     request-pull
このように、TABを押下するだけで、使えるコマンド名がずらっと並びます。 もっと細かく設定したら更に便利になりそうですね