gitで今いるブランチを表示

zsh で今作業している branch を表示させる, というのを試してみた. これは便利だ.

# get the name of the branch we are on
git_prompt_info() {
 ( [ -d .git ] && ref=$(git-symbolic-ref HEAD 2> /dev/null)) || return
 echo "git:${ref#refs/heads/}|"
}
...
RPROMPT=$'%{$fg_bold[red]%}$(git_prompt_info)%{$fg_bold[white]%}%B%(5~,%-2~/.../%1~,%~)%b'

早く CVS を捨てたい, とか切に願う.