Forked from brettstimmerman/gist:382508
Created
September 14, 2023 04:02
Revisions
-
brettstimmerman revised this gist
Apr 28, 2010 . 1 changed file with 12 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,20 @@ # Returns (svn:<revision>:<branch|tag>[*]) if applicable svn_prompt() { if [ -d ".svn" ]; then local branch dirty rev info=$(svn info 2>/dev/null) branch=$(svn_parse_branch "$info") # Uncomment if you want to display the current revision. #rev=$(echo "$info" | awk '/^Revision: [0-9]+/{print $2}') # Uncomment if you want to display whether the repo is 'dirty.' In some # cases (on large repos) this may take a few seconds, which can # noticeably delay your prompt after a command executes. #[ "$(svn status)" ] && dirty='*' if [ "$branch" != "" ] ; then echo "(svn:$rev:$branch$dirty)" fi fi } @@ -23,24 +23,21 @@ svn_prompt() { svn_parse_branch() { local chunk url=$(echo "$1" | awk '/^URL: .*/{print $2}') echo $url | grep -q "/trunk\b" if [ $? -eq 0 ] ; then echo trunk return else chunk=$(echo $url | grep -o "/releases.*") if [ "$chunk" == "" ] ; then chunk=$(echo $url | grep -o "/branches.*") if [ "$chunk" == "" ] ; then chunk=$(echo $url | grep -o "/tags.*") fi fi fi echo $chunk | awk -F/ '{print $3}' } export PS1="\w\$(svn_prompt)>" -
brettstimmerman revised this gist
Apr 28, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Returns (svn:<revision>:<branch|tag>[*]) if applicable svn_prompt() { if [ -d ".svn" ] ; then local branch dirty rev info=$(svn info 2>/dev/null) branch=$(svn_parse_branch "${info}") -
brettstimmerman revised this gist
Apr 28, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Returns (svn:<revision>:<branch|tag>[*]) if applicable svn_prompt() { if [[ -d ".svn" ]] ; then local branch dirty rev info=$(svn info 2>/dev/null) branch=$(svn_parse_branch "${info}") -
brettstimmerman created this gist
Apr 28, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ # Returns (svn:<revision>:<branch|tag>[*]) if applicable svn_prompt() { if [ -d ".svn" ] ; then local branch dirty rev info=$(svn info 2>/dev/null) branch=$(svn_parse_branch "${info}") # Uncomment if you want to display the current revision. #rev=$(echo "${info}" | awk '/^Revision: [0-9]+/{print $2}') # Uncomment if you want to display whether the repo is 'dirty.' In some # cases (on large repos) this may take a few seconds, which can # noticeably delay your prompt after a command executes. #[ "$(svn status)" ] && dirty='*' if [ "$branch" != "" ] ; then echo "(svn:${rev}:${branch}${dirty})" fi fi } # Returns the current branch or tag name from the given `svn info` output svn_parse_branch() { local chunk url=$(echo "$1" | awk '/^URL: .*/{print $2}') echo ${url} | grep -q "/trunk\b" if [ $? -eq 0 ] ; then echo trunk return else # first check /branches/releases chunk=$(echo ${url} | grep -o "/releases.*") if [ "${chunk}" == "" ] ; then # then check for some other branch chunk=$(echo ${url} | grep -o "/branches.*") if [ "${chunk}" == "" ] ; then # last check for a tag chunk=$(echo ${url} | grep -o "/tags.*") fi fi fi echo ${chunk} | awk -F/ '{print $3}' } export PS1="\w$(svn_prompt)>"