Just do IT

思うは招く

git でタブ補完する設定方法

MacOSでもLinuxでも共通する方法。

設定に必要なファイルをまずダウンロードする。

curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash

もしかしたらLinuxだとcurlコマンドが入ってない場合があるのでインストールする。

# Debian使用
sudo apt install curl

.bashrcに以下を追記。

echo "source ~/.git-completion.bash" >> ~/.bashrc

.bashrcを再読み込み。

source ~/.bashrc

これでGitコマンドのオプションやブランチ名などもタブを押せば補完できる。