㌰クラ雑記

㌰㌰クラゲの雑な戯言です

gitの情報をプロンプトに出す

WSLのLinuxbashの場合

git/git-prompt.sh at master · git/git · GitHub

ここのやつをローカルに持ってきて編集して、指定の場所に .git-prompt.sh という名前で置く。

併せて .git-compeletion.bash も持ってくる。

なお .bashrc に追記する部分は

# enable git-compeletion and git-prompt

source ~/.git-compeletion.bash
source ~/.git-prompt.sh

# customize prompt and to show current git branch into current directory zone
# \[\033[01;32m\]\u\h -> user-name and host:
# -> [01;32m\] is font and color (01 = normal font + bold, 32 = green)
# \[\033[01;34m\] \w -> \w current directory:
# -> [01;34m\] is font color blue for current directory (34 = blue)
# \[\033[01;31m\]$(__git_ps1 "(%s)") -> git branch info (import from ~/.git-completion.bash and ~./git-prompt.sh):
# -> [01;31m\] is font color red for git info (31 = red)
# \[\033[01;33m\]\$ -> show shell is turning on (like # front of command):
# -> [01;33m\] is font color yellow for # (33 = yellow)
# \[\033[00m\] is for command zone (maybe 00m is command not to apply any color)

export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \[\033[01;31m\]$(__git_ps1 "(%s)") \[\033[01;33m\]\$\[\033[00m\] '

を参照されたし。