How can I have a shell for git like in Windows?

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?


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.


For color:

git config --global color.ui true

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.