Skip to content

Instantly share code, notes, and snippets.

@lfranchi
Created October 4, 2012 21:03
Show Gist options
  • Save lfranchi/3836443 to your computer and use it in GitHub Desktop.
Save lfranchi/3836443 to your computer and use it in GitHub Desktop.
git_branch() {
BRANCH_REFS=$(git symbolic-ref HEAD 2>/dev/null) || return
echo "(${BRANCH_REFS#refs/heads/}) "
}
svn_branch() {
[ -d .svn ] || return
SVN_INFO=$(svn info 2>/dev/null) || return
SVN_BRANCH=$(echo $SVN_INFO | grep URL: | grep -oe '\(trunk\|branches/[^/]\+\|tags/[^/]\+\)')
[ -n "$SVN_BRANCH" ] || return
# Display tags intentionally so we don't write to them by mistake
echo "(${SVN_BRANCH#branches/}) "
}
if [[ $USER == "root" ]]
then
PROMPT='%{$fg_bold[magenta]%}%m %{$fg_bold[blue]%}# %b%f'
elif [ -n "${SSH_CONNECTION}" ]
then
PROMPT='%{$fg_bold[cyan]%}%m %{$fg_bold[blue]%}# %b%f'
else
PROMPT='%{$fg_bold[green]%}%m %{$fg_bold[blue]%}# %b%f'
fi
RPROMPT='%{$fg_bold[red]%}$(git_branch)%{$fg_bold[yellow]%}$(svn_branch)%b[%{$fg_bold[blue]%}%~%b%f]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment