# This little script allows you to see the current state # of your version-controlled project. # At the right side of the prompt various status information # can be shown: # - Projectname (directory name) # - Incoming changes (y/n) # - Outgoing changes (y/n) # - Uncommited changes (y/n) # # Using the VCSNOREMOTE environment variable there will # be no internet access (and no information whether there # are incoming/outgoing changes available). # # The scripts are tailored towards Mercurial, but should # be easy enough to adapt to other VCSs. # # The information is updated every 60 seconds (and shown after # a new prompt had to be drawn), or if a directory is changed. # # License: do what you want with it export PERIOD=60 chpwd() { RPROMPT=$(updatePrompt) } periodic() { RPROMPT=$(updatePrompt) } updatePrompt() { if [ ! -e "`hg root`/.vcspromptignore" ] then VCSstatus="$(incomingVCS)$(outgoingVCS)$(commitVCS)" if [ ! -z $VCSstatus ] then VCSrootHlpr=`hg root` VCSroot=$VCSrootHlpr:t echo "$VCSroot: $VCSstatus" return fi fi } incomingVCS() { if [ -z "$VCSNOREMOTE" ] then hg incoming -q >> /dev/null 2>&1 if [ $? -eq 0 ] then echo "I" return fi fi } outgoingVCS() { if [ -z "$VCSNOREMOTE" ] then hg outgoing -q >> /dev/null 2>&1 if [ $? -eq 0 ] then echo "O" return fi fi } commitVCS() { if [ ! -z `hg st -q 2> /dev/null` ] then echo "U" return fi }