/ Published in: Bash
Put this into your ~/.bashrc script and you should see the Git/SVN status in your prompt if your working directory is a sandbox.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# Prompt setup, with SCM status parse_git_branch() { local DIRTY STATUS STATUS=$(git status 2>/dev/null) [ $? -eq 1 ] || return [[ "$STATUS" == *'working directory clean'* ]] || DIRTY=' *' echo "($(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* //')$DIRTY)" } parse_svn_revision() { local DIRTY REV=$(svn info 2>/dev/null | grep Revision | sed -e 's/Revision: //') [ "$REV" ] || return [ "$(svn st)" ] && DIRTY=' *' echo "(r$REV$DIRTY)" } PS1='\u@\h:\W$(parse_git_branch)$(parse_svn_revision) \$ ' # alternative version of parse_svn_revision() parse_svn_revision() { local REV=$(svnversion 2>/dev/null) [ $? -eq 0 ] || return [ "$REV" == 'exported' ] && return echo "($REV)" }
URL: http://www.entropy.ch/blog/Developer/2009/03/30/Git-and-SVN-Status-in-the-Bash-Prompt.html