Created
November 17, 2011 11:34
-
-
Save lazywithclass/1372959 to your computer and use it in GitHub Desktop.
Version control aware ps1
This file contains 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 characters
. /etc/bash_completion.d/git | |
function customW { | |
echo $PWD | sed 's|.*/\([a-Z0-9][a-Z0-9]*/[a-Z0-9][a-Z0-9]*\)|\1|' | |
} | |
function hasToPush { | |
git diff-index --quiet --cached HEAD &>/dev/null && | |
(git svn dcommit --dry-run 2>/dev/null | grep -q "diff-tree" && echo "↑") | |
} | |
function hasToPull { | |
git diff-index --quiet --cached HEAD &>/dev/null && ( | |
latest=$(git svn log | awk 'NR==2' | cut -d ' ' -f1 | tr -d 'r') | |
current=$1 | |
(($latest > $current)) && echo "↓" | |
) | |
} | |
function discoverScmInfo { | |
gitPs1=$(__git_ps1) | |
if [ "x$gitPs1" != "x" ]; then | |
gitsvn=$(git svn info 2> /dev/null | grep Revision) | |
gitsvn=${gitsvn#Revision: } | |
if [ "x$gitsvn" != "x" ]; then | |
echo "${gitPs1}($gitsvn$(hasToPull $gitsvn)$(hasToPush))" | |
else | |
echo "$gitPs1" | |
fi | |
fi | |
} | |
PS1='$(customW)$(discoverScmInfo)\$ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment