Skip to content

Instantly share code, notes, and snippets.

@akio0911
Created January 12, 2010 13:13
Show Gist options
  • Save akio0911/275173 to your computer and use it in GitHub Desktop.
Save akio0911/275173 to your computer and use it in GitHub Desktop.
# git のブランチ名前を表示
_set_env_git_current_branch() {
GIT_CURRENT_BRANCH=$( git branch &> /dev/null | grep '^\*' | cut -b 3- )
}
_update_rprompt () {
if [ "`git ls-files 2>/dev/null`" ]; then
RPROMPT="[%~:$GIT_CURRENT_BRANCH]"
else
RPROMPT="[%~]"
fi
}
precmd()
{
_set_env_git_current_branch
_update_rprompt
}
chpwd()
{
_set_env_git_current_branch
_update_rprompt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment