Setting colors for prompt in Git Bash on Windows

I’ve successfully played around with some of the color settings in the Git Bash on Windows – I’m able to set a few things, like the colors of the local, the current and remote branches in my .gitconfig file:

[color "branch"]
current = cyan bold
local = cyan 
remote = red

But what I haven’t managed to change are the colors of the prompt – the username@machine at the beginning of the line (in the yellow rectangle in my screenshot), and the project and branch I’m currently on (purple rectangle).

  • Why is “MINGW64” appearing on my Git bash?
  • Can not activate a virtualenv in GIT bash mingw32 for Windows
  • Running System32 programs instead of SysWOW64 when launching from MINGW
  • Get the modified files
  • How can you access an environment variable that has a space in its name in bash?
  • Find total size of uncommited or untracked files in git
  • enter image description here

    Is there a way to influence those, too? Which .gitconfig settings do I need to set to change those colors?

  • Automate Deployments with Git, Bitbucket and PHP
  • Ignoring .gitignore config/database.yml in a rails project
  • Out of a git console: how do I execute a batch file and then return to git console?
  • git: get effective GIT_DIR, if current dir is a working tree subdir and $GIT_DIR is unset
  • The svn repository I've imported into git using git-svn has moved
  • How do I reset all deleted files
  • One Solution collect form web for “Setting colors for prompt in Git Bash on Windows”

    In your .bashrc you can set your prompt using the PS1 variable (which is likely set to a global value in /etc/profile or another file in /etc which may be distribution dependent).

    Here’s an example:

    PS1='\[\033[1;36m\]\u@\h:\[\033[0m\]\[\033[1;34m\]\w\[\033[0m\] \[\033[1;32m\]$(__git_ps1)\[\033[0m\]\$ '

    In order for the command substitution to work, you need shopt -s promptvars which is the default.

    This will output the user and hostname in cyan, the current directory in blue and the git branch in green on terminals that work with TERM=xterm-color.

    See man 5 terminfo and man tput for more information about terminal controls.

    Git Baby is a git and github fan, let's start git clone.