LoginSignup
16
16

More than 5 years have passed since last update.

Gitで補完機能を有効にする方法

Last updated at Posted at 2014-08-17

やること

1.~/.git-completion.bashファイルを作成

vim ~/.git-completion.bash

git-completion.bashファイルの中身はこちら
https://github.com/git/git/blob/master/contrib/completion/git-completion.bash

2.上で作成したファイルを読み込むよう設定

vim ~/.bashrc

~/.bashrcsource ~/.git-completion.bashを書き込む

【追記】
すべてのユーザーに対して Git 用の Bash シェル補完を使わせたい場合は、

  • Mac → /opt/local/etc/bash_completion.d ディレクトリ
  • Linux 系 → /etc/bash_completion.d/ ディレクトリ

~/.git-completion.bashファイルをコピー。Bash は、これらのディレクトリにあるスクリプトを自動的に読み込んでシェル補完を行う。
ホームディレクトリに~/.git-completion.bashを置くだけでは、ホームディレクトリでGit使う時のみ補完が有効になる。

【参考URL】
▼Git の基本 - ヒントと裏技
http://git-scm.com/book/ja/Git-%E3%81%AE%E5%9F%BA%E6%9C%AC-%E3%83%92%E3%83%B3%E3%83%88%E3%81%A8%E8%A3%8F%E6%8A%80
▼ Gitコマンドをタブキーで補完できるようにする
http://mawatari.jp/archives/git-completion-bash
▼Macにbash-completionをインストールし補完を活用する
http://mawatari.jp/archives/install-bash-completion-on-mac

16
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
16
16