Skip to content

Instantly share code, notes, and snippets.

@himelnagrana
Forked from ashikahmad/pretty_prompt
Created May 20, 2014 07:47
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 himelnagrana/dcff8d339b9e0fb2f3a0 to your computer and use it in GitHub Desktop.
Save himelnagrana/dcff8d339b9e0fb2f3a0 to your computer and use it in GitHub Desktop.
# Install and use menlo font-patch from: https://gist.github.com/qrush/1595572
# Setting GIT prompt
b_black=`tput setab 0`
b_red=`tput setab 9`
b_green=`tput setab 2`
b_cyan=`tput setab 14`
b_white=`tput setab 15`
f_black=`tput setaf 0`
f_red=`tput setaf 9`
f_green=`tput setaf 2`
f_cyan=`tput setaf 14`
f_gray=`tput setaf 8`
f_white=`tput setaf 15`
c_clear=`tput sgr0`
branch_color ()
{
if git rev-parse --git-dir >/dev/null 2>&1
then
color=""
if git diff --quiet 2>/dev/null >&2
then
color=${b_green}
else
color=${b_red}
fi
else
# return 0
echo -n ${b_white}
fi
echo -n $color
}
parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
then
gitver="⮀⭠["$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')"]"
else
return 0
fi
echo -e $gitver
}
#It's important to escape colors with \[ to indicate the length is 0
PS1='\n\[${b_cyan}${f_black}\] \u \[${b_white}${f_cyan}\]⮀\[${f_black}\] \W \[${f_white}$(branch_color)\]$(parse_git_branch)\[${b_white}${f_white}\] \[${c_clear}${f_white}\]⮀\[${c_clear}\] '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment