Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I use Windows, the shell (even a standard Windows shell) shows basic information about the git repository when you are in a git repository. Things like the active branch and maybe some color coding.

Is there a way to have the same in Ubuntu?

share|improve this question
what version of git do you have installed in windows? What commands do you run to get this information? Have you tried those commands with the git-core package installed? – jackweirdy Jul 25 '12 at 20:22
On git i have the latest version, but simply if i use the command line and i'm inside a git repository, i see the name of the active branch – Nicola Peluchetti Jul 25 '12 at 20:25

The Windows Git shell, which is really just bash, sets the prompt $PS1 to a long string that includes $(__git_ps1).

__git_ps1 is defined as a function, nearly 100 lines long, that prints the name of the current branch in parentheses.

/etc/profile (which is C:\Program Files (x86)\Git\etc\profile, at least on my system)) invokes /etc/git-completion.bash, which defines the __git_ps1 function, sets $PS1, defines some git-specific completions, among other things.

The git-completion.bash used by Git Bash appears to be based on this.

share|improve this answer
So exactly what i should do to activate this on uBuntu? :) Sorry but i'm new. – Nicola Peluchetti Jul 27 '12 at 12:35

For color:

git config --global color.ui true
share|improve this answer

If you use zsh as your shell, you might find my config files useful. Try source prompt/blocky to see what the prompt looks like in a Git repository.

share|improve this answer
  • How to stop bash prompt colours from escaping has an example. You could copy it from the answer and then use gedit to paste it to the bottom of your the .bashrc file in your home directory (making a backup, first, of course).

  • If the .bashrc file Keith mentions in his answer is part of git it will be licensed with GPL2 so you should be free to past it into your .bashrc file as well. You'll have to grab the /etc/git-completion.bash file and install it somewhere too, and have your new .bashrc reference it.

  • Here's something else you could paste and try from Arturo Fernandez at

 # Displaying git branch inside prompt
 function parse_git_branch {
   git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'

 function proml {
   local       GREEN="\[\033[0;32m\]"
   local       WHITE="\[\033[0;37m\]"

 PS1="[\u@\h \w$GREEN\$(parse_git_branch)]$WHITE\$ "
 PS2='> '
 PS4='+ '
share|improve this answer
Thanks go to Arturo for licensing this with CC. – John S Gruber Aug 13 '12 at 0:52

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.