Skip to content

Instantly share code, notes, and snippets.

@ebassi
Created May 9, 2012 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ebassi/2643643 to your computer and use it in GitHub Desktop.
Save ebassi/2643643 to your computer and use it in GitHub Desktop.
enhancing __git_ps1 with a blacklist
# pretty hacky wrapper around __git_ps1 that checks directories in a blacklist
__git_maybe_ps1 ()
{
local fmt=''
if [ -z "${1-}" ]; then
fmt='(%s)'
else
fmt=${1}
fi
local cur_dir=$( basename $( pwd ))
local print_ps1='yes'
for black in ${GIT_PS1_BLACKLIST}; do
if [[ "${cur_dir}" == *${black}* ]]; then
print_ps1='no'
break;
fi
done
if [ $print_ps1 == 'yes' ]; then
echo $(__git_ps1 "$fmt")
fi
}
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_BLACKLIST='WebKit'
PS1='\e[32m\u\e[39m@\e[32m\h\e[39m:\e[31m\w \e[34m$(__git_maybe_ps1 "(%s)")\e[39m\$\e[0m\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment