Last active
December 16, 2015 09:19
-
-
Save fadhlirahim/5412518 to your computer and use it in GitHub Desktop.
Show current git branch with color
This file contains hidden or 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
GREEN="\[\033[0;32m\]" | |
WHITE="\[\033[1;37m\]" | |
# Get the name of the current git branch | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
# Update the command prompt to be <current_directory>(git_branch) > | |
# Note that the git branch is given a special color | |
function set_my_prompt { | |
PS1="\w$GREEN\$(parse_git_branch)$WHITE\$ " | |
} | |
set_my_prompt | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment