Ubuntu: Git prompt won't colorize


I want my git prompt in bash to colorize (green for clean repos, red for dirty repos). Right now, it shows plain white text no matter the git state of my cwd/repo.



Although there could be a problem in /etc/bash_completion.d/git-prompt, I think you need to wrap PS1=... into a function and set PROMPT_COMMAND. See https://github.com/sengaya/configs-and-scripts/blob/master/.bashrc#L104 and https://github.com/sengaya/configs-and-scripts/blob/master/.bashrc#L16 for an example.


Add this lines to file .gitconfig in your $HOME (create it if it does not exist):

[color]      ui = auto  

Or, alternatively, change it with the git config command:

$ git config --global color.ui auto  

Optionally, leave out --global to apply it only to the current Git repository.


Be sure git will use color with:

git config --global color.ui auto  

Using bash and with git installed from the up-to-date package (1.9.1-1).

Add the following to .bashrc and then restart bash:


You don't need to change your .bashrc file as in the link you posted. That file eventually will be sourced anyway.

See /etc/bash_completion /usr/share/bash-completion/bash_completion /etc/bash_completion.d/git-prompt and, more importantly, /usr/lib/git-core/git-sh-prompt on your system for comments that describe the uses of the above variables (and additional ones).

Changes in already tracked file cause the dirty displays--newly added ones don't. The describe part of the prompt is only displayed when on a detached HEAD.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »