LoginSignup
1
0

More than 1 year has passed since last update.

Gitのタブ補完を設定する

Posted at

環境

Ubuntu 20.4

はじめに

Gitはデフォルトではタグ補完ができるようになっていないため、タブ補完ができるように設定をおこなう。タブ補完をするには、ぐぐるとgit-completion.bashを組み込む方法が多々ヒットされる。動作環境がmacの場合は、その方法でいいのだが、動作環境がUbuntuの場合は、もっと簡単な方法で実現する方法がある。Ubuntuでも、git-completion.bashを使って実現しようと思えばできるようではある。

手順

Gitが入っているようであれば、次のファイルが既に存在しているはずなので、存在していることを確認する。

cat /usr/share/bash-completion/completions/git

上記のgitファイルは、中身を見てのとおり、シェルスクリプトファイルである。gitファイルを実行すれば、それだけでタブ補完ができるようになる。

source /usr/share/bash-completion/completions/git

タブ補完ができるようになっていることが確認できれば、.bashrcに組み込んで、OS起動時に自動で実行されるようにする

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

./bashrcの中身を見て、最終行に1行追加されていることを確認する

vi ~./bashrc
1
0
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
1
0