Gitのコマンドを自動補完する

Shunsuke Sawada

git checkout feature/my-awesome-branch とか打たなくて良いように、Gitのコマンドは自動補完してもらいたい。

Homebrew

何はともあれ Homebrew をインストールしましょう。

1
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

まずはbashの自動補完

1
brew install bash-completion

設定ファイルに追記

1
vim ~/.bash_profile
~/.bash_profile
1
2
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"

Gitの自動補完

GitもHomebrew経由でインストールします。

1
brew install git

設定ファイルに追記

1
vim ~/.zshrc 
~/.zshrc
1
2
3
4
5
fpath=($(brew --prefix)/share/zsh/site-functions $fpath)

autoload -U compinit
compinit -u

## 参考

Shunsuke Sawada

おすすめの記事

RubyonRailsをApacheとPassengerで動かす
RSpec Capybara Webkit Xvfb CentOS 要するにRailsでjavascriptをテストしたい
30
herokuでRailsアプリを公開する手順をゆっくり丁寧に。
114