To show your active Git branch in your command prompt, you will need to do the following:
- If you are on a Mac, you can add the code shown below to your
.bash_profile
file. - If you are on Linux, you will add the code shown below to the end of your
.bashrc
file. - If you are on Windows, you probably aren't reading this because Windows provides this behavior by default.
######Uncomment force_color_prompt=yes######
#Parse and display the git branch.
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
HC="\[\033[1m\]"
LC="\[\033[2m\]"
IT="\[\033[3m\]"
PINK="\[\033[038;5;218m\]"
CYAN="\[\033[36m\]"
NO_COLOR="\[\033[0m\]"
KEEPHER="\[\033]12;#ffafd7\a\]"
#CURSOR="\[\033]12;pink\a\]"
#PS1="$PS1$HC$IT$CYAN\$(parse_git_branch)$NO_COLOR "
PS1="$PS1$HC$IT$CYAN\$(parse_git_branch)$NO_COLOR$PINK$KEEPHER "
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\w\[\033[36m\]\$(parse_git_branch) \[\033[00m\] > "
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOR="\[\033[0m\]"
PS1="$GREEN\u@\h$NO_COLOR:\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ "