iamnewton / dotfiles

UNIX-based system configuration for software development
https://github.com/iamnewton/dotfiles#readme
GNU General Public License v3.0
9 stars 3 forks source link

Add SVN status to prompt #30

Closed iamnewton closed 4 years ago

iamnewton commented 10 years ago
# 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
iamnewton commented 10 years ago

Colors might have an issue as well and should be refactored:

iamnewton commented 4 years ago

No longer using SVN anywhere.