Created
February 10, 2014 21:44
-
-
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.
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
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