Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I have the 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 ~/

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\])")\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1 " (\[\033[01;33m\]%s\[\033[00m\])")\$ '
unset color_prompt force_color_prompt
share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

# this is only a outline of possible code 
function myFancyGitPS1() {
   case $(pwd) in
           __git_ps1 " (\[\033[01;33m\]%s\[\033[00m\])"
share|improve this answer
groans It's always the obvious solutions that are so hard to see... Thanks heaps :) It's working perfectly now. – Valorin Mar 12 '13 at 21:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.