Skip to content

Instantly share code, notes, and snippets.

@wsams
Created September 16, 2015 20:54
Show Gist options
  • Save wsams/9b35d3af82283746d510 to your computer and use it in GitHub Desktop.
Save wsams/9b35d3af82283746d510 to your computer and use it in GitHub Desktop.
Show new, removed, clean repository state icons while using svn-prompt.sh and git-prompt.sh
# https://github.com/mcandre/svn-prompt
function setSvnPrompt {
svn info &>/dev/null
if [ $? -eq 0 ]; then
svn st | grep "[0-9a-zA-Z?\!]" > /dev/null 2>&1
if [ $? -eq 1 ]; then
# nothing changed
echo -n "✓ "
fi
svn status | grep "^?" > /dev/null 2>&1
if [ $? -eq 0 ]; then
# new files
echo -n "★ "
fi
svn status | grep "^M" > /dev/null 2>&1
if [ $? -eq 0 ]; then
# modified files
echo -n "☢ "
else
svn status | grep "^\!" > /dev/null 2>&1
if [ $? -eq 0 ]; then
# modified files
echo -n "☢ "
else
svn status | grep "^A" > /dev/null 2>&1
if [ $? -eq 0 ]; then
# modified files
echo -n "☢ "
fi
fi
fi
svn status | grep "^D" > /dev/null 2>&1
if [ $? -eq 0 ]; then
# deleted files
echo -n "✂ "
fi
parse_svn_branch
else
echo ""
fi
}
function parse_svn_branch {
parse_svn_url | sed -e 's#^'"$(parse_svn_repository_root)"'##g' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$' | awk '{print "("$1") svn" }'
}
function parse_svn_url {
svn info 2>/dev/null | sed -ne 's#^URL: ##p'
}
function parse_svn_repository_root {
svn info 2>/dev/null | sed -ne 's#^Repository Root: ##p'
}
if [ $UID -eq 0 ]; then
userindicator="#"
else
userindicator='$'
fi
Color_Off="\[\033[0m\]"
PS1="\[\n\]\[\`if [ \$? = 0 ]; then echo \"\e[38;05;28m\]:)\[\"; else echo \"\e[38;05;196m\"\]:\(\[; fi\`\e[m \]\d\[ \]\t\[ \[\e[32m\]\]\u@\h\[ \[\e[35m\]\]\w\[\e[0m\] \$(setSvnPrompt) $Color_Off\n${userindicator} "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment