Skip to content

Instantly share code, notes, and snippets.

@DannyFeliz
Created October 13, 2015 16:32
Show Gist options
  • Save DannyFeliz/584545341a24cd080697 to your computer and use it in GitHub Desktop.
Save DannyFeliz/584545341a24cd080697 to your computer and use it in GitHub Desktop.
show branch name in command line
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