bashにgitとmercurialのブランチ名を表示する
環境
- Ubuntu 11.04
変更箇所
.bashrc の「PS1=....」みたいな所を下記のような感じで変更する。
- .bashrc
# prompt command hg_branch() { hg branch 2> /dev/null | awk '{printf "(hg:" $1 ")"}' } git_branch() { __git_ps1 '(git:%s)' } if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(git_branch)$(hg_branch)\n\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(git_branch)$(hg_branch)\n\$ ' fi unset color_prompt force_color_prompt