Skip to content

Instantly share code, notes, and snippets.

@schuyler1d
Created June 15, 2011 16:13
Show Gist options
  • Save schuyler1d/1027442 to your computer and use it in GitHub Desktop.
Save schuyler1d/1027442 to your computer and use it in GitHub Desktop.
bashrc for git status prompt
function git_current {
BRANCH_NAME=`git branch -v 2>/dev/null |grep '^*'|awk '{print substr($2,0,6)}'`
BRANCH_HASH=`git branch --abbrev=4 -v 2>/dev/null |grep '^*'|grep -o ' [0-9a-f][0-9a-f][0-9a-f][0-9a-f] '`
echo -n $BRANCH_NAME $BRANCH_HASH
}
RIGHT_PROMPT='\[\033[s\]\[\033[$((COLUMNS-16))C\]'
END_RIGHT_PROMPT='\[\033[u\]'
DEB_PREFIX='${debian_chroot:+($debian_chroot)}'
COL_FG='\[\033[00m\]'
USER_HOSTNAME_TRUNCATED='${USER:0:1}@${HOSTNAME:0:4}'
USER_HOSTNAME='${USER:0:4}@${HOSTNAME:0:11}'
COL_WHITE='\[\033[01;37m\]'
COL_BLUE='\[\033[01;34m\]'
PWD_PROMPT='\w'
PWD_TRUNCATED='${PWD:0-20}'
COL_BROWN='\[\033[0;33m\]'
GIT_PROMPT='$(git_current)'
PS1="${DEB_PREFIX}${COL_WHITE}${USER_HOSTNAME_TRUNCATED}:${COL_BLUE}${PWD_PROMPT} ${COL_BROWN}${GIT_PROMPT}${COL_FG} \$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment