Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash で git を g などで alias を設定しているときでも git-completion で補完できるようにする #55

Open
shikakun opened this issue Feb 10, 2014 · 1 comment

Comments

@shikakun
Copy link
Owner

git って打つのが大変だから g と打っただけで git って書いたことにできるように .bashrc で alias を設定しているけど、g って打ったときは git-completion のブランチ名の補完が効かなかった。ブランチ名を補完したいときは git ってちゃんと書くことで生活してた。しかし、g と打ったときも git-completion の補完を利用できるようにする方法があった!

git-completion を利用するために、.bashrc または .bash_profile に以下のようなパスを指定している記述があると思う。書いてなくても利用できる方法あるのかな…?

source /usr/local/git/contrib/completion/git-prompt.sh
source /usr/local/git/contrib/completion/git-completion.bash

自分の環境では .bashrc に、上記のように指定してあった。
/usr/local/git/contrib/completion/git-completion.bash を好きなエディタで開いて、末尾に以下のコードを追記する。

complete -o bashdefault -o default -o nospace -F _git g 2>/dev/null \
  || complete -o default -o nospace -F _git g

保存して $ source ~/.bashrc を実行して再読み込みすると、g だけ打ってもブランチ名の補完が効くようになった。やったー!

参考

@MoyuruAizawa
Copy link

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants