0
0

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のブランチ名や状態を表示させる

Last updated at Posted at 2018-06-07

Why

aliasに指定していないgitコマンドを入力する際にオプションを入力するのが煩わしい

How

gitコマンドの補完スクリプトの導入

条件

bashを利用している(zshについては割愛)

既にXcodeなどでインストールされている場合もあるので、検索をすることをお勧めします。
$ find / -name "git-prompt.sh" -print

見つからない場合はダウンロードします。
https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh

.bashrcを下記のように編集

source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh

GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUPSTREAM=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWSTASHSTATE=1

export PS1='\[\033[1;32m\]\u\[\033[00m\]:\[\033[1;34m\]\w\[\033[1;31m\]$(__git_ps1)\[\033[00m\] \$ '
0
0
0

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?