From a6a3b5bc9a8c0142d2779894c2ca43241b7adefc Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 9 Jul 2012 13:46:48 -0400 Subject: [PATCH] bash_aliases: add prompt_ps1_svn_branch() --- bash_aliases | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bash_aliases b/bash_aliases index 7676ec7..ab1d3e3 100755 --- a/bash_aliases +++ b/bash_aliases @@ -2,7 +2,7 @@ if [[ "`whoami`" == "root" ]]; then PS1='\[\033[31;1m\]\u@\H\[\033[32;1m\] [\w]\[\033[35;1m\] \d \t \[\033[34;1m\](\j)\n\$ \[\033[0m\]' else - PS1='\[\033[32;1m\]\u@\H\[\033[31;1m\] [\w]\[\033[35;1m\] \d \t \[\033[34;1m\](\j)\[\033[33;1m\]$(prompt_ps1_git_branch)\[\033[34;1m\]\n\$ \[\033[0m\]' + PS1='\[\033[32;1m\]\u@\H\[\033[31;1m\] [\w]\[\033[35;1m\] \d \t \[\033[34;1m\](\j)\[\033[33;1m\]$(prompt_ps1_git_branch)$(prompt_ps1_svn_branch)\[\033[34;1m\]\n\$ \[\033[0m\]' fi # alternate PS1: # PS1='[\[\033[31;1m\]\u@\H\[\033[34;1m\] \w\[\033[0m\]]\$ \[\033[0m\]' @@ -54,6 +54,19 @@ function prompt_ps1_git_branch() fi } #put $(prompt_ps1_git_branch) in $PS1 to use it +function prompt_ps1_svn_branch() +{ + which_svn=$(which svn) + if [[ "$which_svn" == "" ]]; then + return + fi + url_out=$(svn info 2>/dev/null | grep '^URL:' | grep -E '\<(trunk|tags|branches)\>') + if [[ "$url_out" == "" ]]; then + return + fi + filter=$(echo "$url_out" | sed -re 's/.*\.*$/trunk/' -e 's/.*\<(tags|branches)\/([^\/]*).*$/\2/') + echo " [${filter}]" +} alias ls='ls --color=auto' alias strip-cr="sed -e 's/\x0d//'" alias rip='abcde -x -p -o mp3:"-v -b160"'