Created
October 13, 2015 16:32
-
-
Save DannyFeliz/584545341a24cd080697 to your computer and use it in GitHub Desktop.
show branch name in command line
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
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
BLUE="\[\033[00m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[01;32m\]" | |
NO_COLOR="\[\033[0m\]" | |
OTHER="\[\033[01;36m\]" | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/" | |
} | |
PS1="$GREEN\u@\h$BLUE:$OTHER\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ " | |
unset color_prompt force_color_prompt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment