Skip to content

Instantly share code, notes, and snippets.

@lynxluna
Created February 10, 2014 21:44
Show Gist options
  • Save lynxluna/8924828 to your computer and use it in GitHub Desktop.
Save lynxluna/8924828 to your computer and use it in GitHub Desktop.
My most important bash profile to set up my prompt and console coloring.
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
function gitify {
default_prompt="-----------------------------------------\n\e[37;1m[ \w ]\e[0m\] @ \h (\u) \n=> "
git rev-parse --git-dir >/dev/null 2>&1
if [ $? -eq 0 ]; then
light_green="\[\033[1;32m\]"
light_yellow="\[\033[1;33m\]"
light_red="\[\033[1;31m\]"
reset="\[\e[0m\]"
current_branch=`git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
current_status=`git status 2>/dev/null`
if [[ $current_status =~ "Changed" ]]; then
branch_color=$light_yellow
elif [[ $current_status =~ "Your branch is ahead" ]]; then
branch_color=$light_red
else
branch_color=$light_green
fi
PS1="-----------------------------------------\n\e[37;1m[ \w ]\e[0m\] @ \h (\u) \n[git:$branch_color$current_branch$reset]=> "
else
PS1=$default_prompt
fi
}
PROMPT_COMMAND=gitify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment