Last active
December 18, 2015 20:49
-
-
Save lukaszgrolik/5842689 to your computer and use it in GitHub Desktop.
Linux console prompt with git branch
This file contains 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
# ... | |
source ~/.bashrc |
This file contains 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
# ... | |
# 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