Skip to content

Instantly share code, notes, and snippets.

@SamuelTurner
Created September 16, 2016 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SamuelTurner/5b46775ebbd0551e2a96f42d6ac61106 to your computer and use it in GitHub Desktop.
Save SamuelTurner/5b46775ebbd0551e2a96f42d6ac61106 to your computer and use it in GitHub Desktop.
My .bashrc
# Colors for the prompt
blue="\033[0;34m"
white="\033[0;37m"
green="\033[0;32m"
red="\033[0;31m"
purple="\033[0;35m"
# Brackets needed around non-printable characters in PS1
ps1_blue='\['"$blue"'\]'
ps1_green='\['"$green"'\]'
ps1_white='\['"$white"'\]'
ps1_red='\['"$red"'\]'
ps1_purple='\['"$purple"'\]'
parse_git_branch() {
gitstatus=`git status 2> /dev/null`
if [[ `echo $gitstatus | grep "Changes to be committed"` != "" ]]
then
echo -e "${blue}\c"
elif [[ `echo $gitstatus | grep "Changes not staged for commit"` != "" ]]
then
echo -e "${red}\c"
elif [[ `echo $gitstatus | grep "Untracked"` != "" ]]
then
echo -e "${red}\c"
elif [[ `echo $gitstatus | grep "nothing to commit"` != "" ]]
then
echo -e "${green}\c"
else
echo -e "${purple}\c"
fi
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="$ps1_purple\W$ps1_white\$(parse_git_branch) $ps1_purple\$$ps1_white "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment