-
-
Save jaysonrowe/2644001 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 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 "(%s)") | |
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' |
modified the PS1 to include square brackets (my preference)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
__git_maybe_ps1 ()
{
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
}
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_ps1 "(%s)")\e[39m]$ '