I have the git-prompt.sh
script setup in my .bashrc
file which
gives me the useful git information in my prompt. This is great for small repos, but when I cd
into a large repo, it can take a 30+ seconds, for the prompt to respond since it needs to review the git repo first.
It is possible to set up my .bashrc
so that I can either whitelist my small repos for the git prompt to display, or blacklist my large repos so it doesn't load the git prompt?
Alternatively, I'd be happy with a flag/variable that I have to set to enable the git prompt.
The relevant part of my .bashrc
looks like this:
##
# Git prompt options
##
source ~/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWUPSTREAM="auto"
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(__git_ps1 " (\[\033[01;33m\]%s\[\033[00m\])")\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1 " (\[\033[01;33m\]%s\[\033[00m\])")\$ '
fi
unset color_prompt force_color_prompt
Look at the code - the real work is done in a function
__git_ps1
, which is called from inside the prompt.Replace this function by your own function, e.g.