20
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git commandのaliasを作ってる時でも補完して欲しい時

Last updated at Posted at 2015-02-18

これ何とかなんないのかなと思ってたら素晴らしいtipsが見つかったが、そのまま使えなかったのでちょっと変えた

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

#git-completion.bash

多分bashrcかなんかでgit-completion.bash呼び出してると思うので探す
自分の場合はこんなかんじになってる

.bashrc

alias g="git"
source /usr/local/etc/bash_completion.d/git-completion.bash

参考にしたtipsと__git_completeの内容が若干変わっているので__git_complete呼び出しを増やす形で対応する。
一行追加するだけで快適な補完ライフ

git-completion.bash


# Setup completion for certain functions defined above by setting common
# variables and workarounds.
# This is NOT a public function; use at your own risk.
__git_complete ()
{
	local wrapper="__git_wrap${2}"
	eval "$wrapper () { __git_func_wrap $2 ; }"
	complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
		|| complete -o default -o nospace -F $wrapper $1
}

__git_complete git __git_main
__git_complete gitk __gitk_main
__git_complete g __git_main #追加

20
16
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?