Home » Git bash » How to change the display name in Git bash prompt

How to change the display name in Git bash prompt

By Emily

I share screen shots quite a lot in my blog posts and got fed up of needing to blur the user name information from my Git bash terminal screenshots in some cases. The git bash prompt defaults to include your username, and I didn’t want to share that in many cases. So I wanted to find out how to change the git bash prompt to some custom text. This post describes how I edited the configuration file to change the display name in Git Bash. I outline all the steps you need to take in order to edit the git-prompt.sh file to set customised git bash prompt text.

How to change the bash prompt display name

To change the text in the git bash prompt you will need to edit a text file which contains the settings. This file is called git-prompt.sh and can be found in a sub folder under the location of the git-bash.exe file. On my PC that path is:

C:\Program Files\Git\etc\profile.d

How to find the git-bash.exe path

To find the path to git-bash.exe on your system right click the Git Bash icon in your start menu or task bar, then right click the git bash item in the pop up menu, and finally left click the properties item in that sub menu. In the window that appears you can see, and copy, the path to the exe file, as shown here:

Find the path to git-bash-exe
If you copy the path without the git-bash.exe and open that path in Windows explorer, you’ll be in the Git Bash root folder.

Now you need to look for a subfolder called etc and a subfolder in there called profile.d. So the full path on my system is:

C:\Program Files\Git\etc\profile.d

In here you’ll find your git-prompt.sh file. Open it in notepad or Vs Code as we are going to edit it.

What is the git-prompt.sh file?

The git-prompt.sh file contains all of the configuration information for the Git bash terminal and the prompt itself. It contains settings that enable Git Bash to show information about the repository.

How to edit the file git-prompt.sh file to customize Git Bash

There are two ways to edit the file. You can edit the main git-prompt.sh file directly, or you can create a customized one specifically for your user account.

Edit the main file directly

Before you make any changes to the git-prompt file directly, copy it and save that copy in the same folder. You can have that as an original file to roll back to should you do anything that stops git bash working.

Create a custom configuration file for Git Bash

If you open the main git-prompt file you’ll see between lines 8 and 11 it checks to see if a file exists here – ~/.config/git/git-prompt.sh . The ~ part of that file path refers to the folder relating to your username so it will be something like C:\Users\johndoe\. If the folder already exists, then Git Bash loads the configuration data from that file instead of this main file.

On my system there was already a .config folder, so I created a git folder within that. You should then copy the default git-prompt.sh file from here:

 C:\Program Files\Git\etc\profile.d

… and place the duplicate in the folder you just created at:


Now we can safely edit that file, leaving the original default version alone. You need to remove the if then else statement that looks for this custom file, otherwise Git bash will just crash when you try and run it.

Once you’ve done that, from now on when you start Git Bash it will take the configuration from your new customized file. If you ever want to roll back to the original you can just delete your customized file and Git Bash will revert to using the original, untouched file.

Edit git-prompt.sh file to change git bash prompt text

All I’ve done here is remove that block and then edit the cursor text to say brainstorm as shown here:

customize git bash prompt

You could copy this text to use as the starting point for your custom file – git-prompt.sh.

if test -f /etc/profile.d/git-sdk.sh

	PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]' # set window title
	PS1="$PS1"'\n'                 # new line
	PS1="$PS1"'\[\033[32m\]'       # change to green
	PS1="$PS1"'brainstorm '        # user@host<space> ----- this is where I have edited the name
	PS1="$PS1"'\[\033[35m\]'       # change to purple
	PS1="$PS1"'$MSYSTEM '          # show MSYSTEM
	PS1="$PS1"'\[\033[33m\]'       # change to brownish yellow
	PS1="$PS1"'\w'                 # current working directory
		GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)"
		if test -f "$COMPLETION_PATH/git-prompt.sh"
			. "$COMPLETION_PATH/git-completion.bash"
			. "$COMPLETION_PATH/git-prompt.sh"
			PS1="$PS1"'\[\033[36m\]'  # change color to cyan
			PS1="$PS1"'`__git_ps1`'   # bash function
	PS1="$PS1"'\[\033[0m\]'        # change color
	PS1="$PS1"'\n'                 # new line
	PS1="$PS1"'$ '                 # prompt: always $

MSYS2_PS1="$PS1"               # for detection by MSYS2 SDK's bash.basrc

# Evaluate all user-specific Bash completion scripts (if any)
	for c in "$HOME"/bash_completion.d/*.bash
		# Handle absence of any scripts (or the folder) gracefully
		test ! -f "$c" ||
		. "$c"

Now you.ve finished editing the file to change the name in your Git bash display name.

I’ll be following up with another post soon about how to customize the Git bash terminal colours. In the mean time you may find this post useful as it tells you how to change the default folder / directory in git bash, along with some other useful tips.