branch わからないと不安になってくるので表示るように。typo さんの真似。ただ refs とか長いのはいらないので git-branch コマンドで。0.001秒以下で終わるので毎回 chpwd 時に走ってもいいや感。
また、zsh 4.3.4 から入った zsh-templates を使ってみる。( http://xanana.ucsc.edu/~wgscott/wordpress_new/wordpress/?p=12 ) これ使うと preexec や chpwd がすっきりかけていいね。
typeset -ga chpwd_functions
function _screen_title_chpwd() {
if [ "$TERM" = "screen" ]; then
echo -n "^[k[`basename $PWD`]^[\\"
fi
}
functions _set_rprompt_git() {
local -A git_res
git_res=`/usr/bin/git branch -a --no-color 2> /dev/null `
if [ $? != '0' ]; then
RPROMPT=$RPROMPT_DEFAULT
else
git_res=`echo $git_res|grep '^*'|tr -d '\* '`
RPROMPT=' %{^[[32m%}('$git_res')%{^[[00m%} '$RPROMPT_DEFAULT
fi
}
functions _xxx_ls() {
ls
}
chpwd_functions+=_xxx_ls
chpwd_functions+=_screen_title_chpwd
chpwd_functions+=_reg_pwd_screennum
chpwd_functions+=_set_rprompt_git