Skip to content

Instantly share code, notes, and snippets.

@schuyler1d
Created December 21, 2011 15:32
Show Gist options
  • Save schuyler1d/1506437 to your computer and use it in GitHub Desktop.
Save schuyler1d/1506437 to your computer and use it in GitHub Desktop.
Git status in bash prompt
function git_current {
git branch -v 2>/dev/null |grep '*'|awk '{print substr($2,0,6) " " substr($3,0,3)}'
}
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