Created
June 12, 2014 16:00
-
-
Save lewisd32/2056c17d7200e615f20e to your computer and use it in GitHub Desktop.
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 characters
export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w$(tag)\$ ' | |
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 characters
Prompt output: | |
lewisd@transistor:~/projects/lp-webapp\[\][master(1)]\[\]$ |
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 characters
#!/bin/sh | |
# Check CVS | |
if [ -f ./CVS/Tag ]; then | |
tag=`cat ./CVS/Tag | awk '{ print substr($0,2) }'` | |
# If not CVS, then check SVN | |
elif [ -d .svn ]; then | |
svnInfo=$( svn info | grep --colour=never 'URL' | sed -e 's#URL: http://svn.riptown.com/##g' | sed -r -e 's#(.*)/(trunk|branches|tags)/(.*)#\2/\3#g' ) | |
# Is it the trunk? | |
if echo $svnInfo | grep --colour=never -q '.*/trunk/'; then | |
tag='' | |
# Is it a branch? | |
elif echo $svnInfo | grep --colour=never -q 'branches/'; then | |
tag=`echo $svnInfo | sed -r -e 's#branches/([^/]*).*#\1#g'` | |
# Is it a tag (i.e. version)? | |
elif echo $svnInfo | grep --colour=never -q 'tags/'; then | |
tag=`echo $svnInfo | sed -r -e 's#tags/([^/]*).*#\1#g'` | |
fi; | |
fi; | |
#hg_branch=`hg branch` | |
#if ( "$hg_branch" != "default" ); then | |
# tag="$hg_branch" | |
#fi | |
if ( git branch > /dev/null 2>&1 ); then | |
tag=`git branch | grep "^\*" | sed "s/^\* //"` | |
commits=$(git log origin.. 2>/dev/null | grep ^commit | wc -l) | |
exclam=$(git status --porcelain | grep -qv "^??" && echo "!") | |
if [ $commits -gt 0 ]; then | |
tag="\[$(tput setaf 1)$(tput bold)\][$exclam$tag($commits)$exclam]\[$(tput sgr0)\]" | |
else | |
tag="\033[1;32m[$exclam$tag$exclam]\033[0m" | |
fi | |
fi | |
#Print the tag out if it's not empty | |
[ -n "$tag" ] && echo $tag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment