Skip to content

Instantly share code, notes, and snippets.

@SamuelTurner SamuelTurner/.bashrc
Created Sep 16, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.