# Determine the branch information for this subversion repository. No support
# for svn status, since that needs to hit the remote repository.
prompt_svn() {
local s=""
local branchName=""
local base08=$(tput setaf 210) # red
local base09=$(tput setaf 209) # orange
local base0A=$(tput setaf 221) # yellow
local base0B=$(tput setaf 114) # green
local base0F=$(tput setaf 173) # brown
local branchStyle="$base0B"
# Capture the output of the "git status" command.
local svn_info="$(svn info | egrep '^URL: ' 2> /dev/null)"
# Get the name of the branch.
local branch_pattern="^URL: .*/(branches|tags)/([^/])"
local trunk_pattern="^URL: .*/trunk(/.*)?$"
if test -d '.svn' &>/dev/null; then
if [[ ${svn_info} =~ $branch_pattern ]]; then
branch=${BASH_REMATCH[2]}
elif [[ ${svn_info} =~ $trunk_pattern ]]; then
branch='trunk'
fi
# Set the final branch string.
printf "%s" " on (${branch})"
else
return
fi
}
PS1+="\[$reset\]\$(prompt_svn)" # svn repository details