Created
May 9, 2012 10:38
-
-
Save ebassi/2643643 to your computer and use it in GitHub Desktop.
enhancing __git_ps1 with a blacklist
This file contains 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
# 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