Skip to content

Instantly share code, notes, and snippets.

@lukaszgrolik
Last active December 18, 2015 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaszgrolik/5842689 to your computer and use it in GitHub Desktop.
Save lukaszgrolik/5842689 to your computer and use it in GitHub Desktop.
Linux console prompt with git branch
# ...
source ~/.bashrc
# ...
# Append current git branch in prompt
parse_git_branch() {
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
echo " ($git_branch)"
}
PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]\[\033[01;34m\] \w\[\033[00m\]\[\033[01;33m\]\$(parse_git_branch)\[\033[00m\] \n\[\033[01;37m\]$ \[\033[00m\]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment