Skip to content

Instantly share code, notes, and snippets.

@jaysonrowe
Forked from ebassi/git-ps1-bashrc.sh
Created May 9, 2012 11:57
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 jaysonrowe/2644001 to your computer and use it in GitHub Desktop.
Save jaysonrowe/2644001 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 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'
@jaysonrowe
Copy link
Author

__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_ps1 "(%s)")\e[39m]$ '

@jaysonrowe
Copy link
Author

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