public
Description: Utilities for Git users
Homepage:
Clone URL: git://github.com/cv/git-utils.git
git-utils / git-PS1
100644 17 lines (14 sloc) 0.42 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
#
# Taken from http://kerneltrap.org/mailarchive/git/2006/11/16/230518
#
# In your .profile, add:
#
# export PS1='$(git-PS1 "[\u@\h \W]\$ ")'
#
BRANCH=$(git symbolic-ref HEAD 2>/dev/null) || { echo "$@" ; exit ; }
BRANCH=${BRANCH#refs/heads/}
 
RELATIVE=$(git rev-parse --show-prefix)
RELATIVE="${RELATIVE//%\/}"
 
LOCATION="${PWD%/$RELATIVE}"
 
echo "[$BRANCH!${LOCATION/*\/} ${RELATIVE:+/$RELATIVE}]$ "