Informative git prompt for bash and fish – GitHub

This prompt is a port of the “Informative git prompt for zsh” which you can find here

A bash prompt that displays information about the current git repository. In particular, the name of the branch, the difference with the remote branch, the number of files organized, changed, etc. and added by AKS.


The message may look like this:

(master↑3|✚1): in branch master, ahead of remote by 3 commits, 1 file changed but not provisionalized (status|●2): in branch state, 2 staging files (master|✚7…): in branch master, 7 files changed,

    some files not tracked (master|2

  • ✚3): in branch master, 2 conflicts, 3 files changed (master| ✖
  • ⚑2):
  • In the branch master, 2 stash entries (experimental↓2↑3|): in experimental branch; its branch has diverged in 3 confirmations, remote in 2 confirmations; Repository is clean (:70c2952

  • |✔): Not in any branch; main commit hashes 70c2952;
  • repository is otherwise clean Message structure By default

  • , the overall appearance of the message is: The symbols are as follows: Local status symbols: clean repository ●n: there are n preconfigured files n: ✔

there are n files

    • with conflicts

    • Merge -n: there are n preconfigured files waiting for deletion ✚n: there are n files modified ✔
    • but not
    • configured
    • n
    • : there are n untraced files

    • n: there are

  • n stash entries

  • Ascending branch
    • Displays remote tracking branch
    • Off by default
    • Enable by setting GIT_PROMPT_SHOW_UPSTREAM=1
  • Branch trace symbols ↑n: ahead of remote by n commits ↓n:

    • behind remote by n

    • commits ↓
    • M↑N: Divergent branches, Others by M Commits, Yours by N Commits
    • L: Local branch, not

    • remotely tracked Branch
  • symbol:

  • When the branch name starts with a colon: it means it’s actually a hash, not a branch (although it should be pretty clear, unless you name your branches as hashes 🙂


via Homebrew on Mac OS X

  • Run Update

  • Run brew install bash-git-prompt for the latest stable version or brew install -HEAD bash-git-prompt for the latest version directly from

  • the repository

  • You can now get the file on your ~/.bash_profile as follows:

via Git

  • clone Clone this repository to your home directory.

Add to ~/.


install for fish shell If you cloned the repository to a directory other than ~/.bash-git-prompt , set __GIT_PROMPT_DIR to ~/.config/fish

    / in that path To install as an option in the GUI fish_config to install

  • bash-git-prompt

  • as an option on

the request tab

of the web configuration. Selecting this will copy it to ~/.config/fish/functions/

  • You can also do


overwrite the current message with the bash-git-prompt directly

All settings for .bashrc

You can set the GIT_PROMPT_SHOW_UNTRACKED_FILES variable to no or normal to speed things up if you have a lot of uncrawled files in your repository. This can be the case for build systems that place their build artifacts in the subdirectory structure of the git repository. Setting it to all will count all untracked files, including files listed in .gitignore.

  • CD to a Git repository and try it!


settings are now stored in theme files. To select a theme, set the GIT_PROMPT_THEME variable to the theme name located in <INSTALLDIR>/themes without the .bgptheme extension like this:

If you set GIT_PROMPT_THEME to Custom, the in the home directory will be used. This file can now be generated with the command git_prompt_make_custom_theme [<Base theme name>]. If the name of the base theme is omitted or the theme file is not found, the default theme is used. If you already have a custom in your home directory, an error message will be displayed.

You can display a list of available themes with git_prompt_list_themes (the current theme is highlighted)

If you omit the GIT_PROMPT_THEME variable, the default theme is used, or, if you have a custom in your home directory, the custom theme is used.



Ubuntu requires a little more space for some characters, so it has its own themes


These can be listed with git_prompt_list_themes:

Theme structure

See the Custom.bgptemplate template in the themes subdirectory of the installation directory.

A theme consists of a

override_git_prompt_colors() function that defines at least the GIT_PROMPT_THEME_NAME variable with a unique theme identifier and a call to the reload_git_prompt_colors <ThemeName> function as follows:

The advantage of this approach is, you only need to specify the parts that are different from the default theme


If you use a custom theme in, set GIT_PROMPT_THEME_NAME=”Custom”.

Other customizations

  • You can define GIT_PROMPT_START and GIT_PROMPT_END to adjust the message

  • .

  • The default colors are defined within, which is obtained by The colors used for various git states are defined in themes/Default.bgptheme. Both files can be overridden by copying them to $HOME with a . prefix. They can also be placed in $HOME/lib without the header.. The default values are the original files in the ~/.bash-git-prompt directory.

  • You can use GIT_PROMPT_START_USER, GIT_PROMPT_START_ROOT, GIT_PROMPT_END_USER, and GIT_PROMPT_END_ROOT in your to fine-tune your message. You can also override the start and end of the message by setting GIT_PROMPT_START and GIT_PROMPT_END before getting the

  • The current information in the git repository is obtained using the script

  • .

  • You can define prompt_callback function to adjust your message dynamically.

  • There are two helper functions that can be used within prompt_callback:

    • gp_set_window_title <String> – sets the window title to the given string (it should work for XTerm type terminals like in OS X or Ubuntu)
    • gp_truncate_pwd – a function that returns the current PWD truncated to fit the current terminal width. Specify the length to truncate as a parameter. Otherwise, the default value is 1/3 of the width of the terminal.
  • If you want to display the git flag

  • only if it is in a git repository, you can set GIT_PROMPT_ONLY_IN_REPO=1 before getting the gitprompt script

  • You can display a shortened username/repository at the prompt by setting GIT_PROMPT_WITH_USERNAME_AND_REPO=1 and setting the _USERNAME_REPO_ placeholder in your GIT_PROMPT_PREFIX. You can also add a GIT_PROMPT_USERNAME_REPO_SEPARATOR=” | ” so the username/repository is well separated if there is a remote control and if there is no remote control, neither the username/repository part nor the separator will be displayed. See the topic Single_line_username_repo.bgptheme for an example.

  • There is an indicator at the beginning of the message, which shows the result of the last command executed if you place the _LAST_COMMAND_INDICATOR_ placeholder in any of the indicator templates.

It is now enabled by default in the default theme:

If you also want to display the exit code, you can use the _LAST_COMMAND_STATE_ placeholder in GIT_PROMPT_COMMAND_OK or GIT_PROMPT_COMMAND_FAIL

in your

  • It is now possible to disable getting from the remote repository either globally by setting GIT_PROMPT_FETCH_REMOTE_STATUS=0 in your .bashrc or by repository by creating a file called .bash-git-rc with the Content FETCH_REMOTE_STATUS=0 in the root of your Git repository.

  • You can also ignore a repository entirely by creating a file called .bash-git-rc with the contents GIT_PROMPT_IGNORE=1 in the root of your git repository.

  • If you have a repository with a lot of uncrawled files, the git flag can become very slow. You can disable the display of files not crawled by repository by setting GIT_PROMPT_SHOW_UNTRACKED_FILES=no in your .bash-git-rc in the repository or disabling it globally in your .bashrc

  • If you have a repository with a deep submodule hierarchy, this can also affect performance. You can disable searching for changes in submodules by repository by setting GIT_PROMPT_IGNORE_SUBMODULES=1 in your .bash-git-rc You

  • can get help at the git prompt with the git_prompt_help function. Examples are available with git_prompt_examples. A list of all available named colors is available with git_prompt_color_samples

  • If you make changes to any file that originates from, you must run this command so that the next request update finds all the files and gets them back.

  • You can disable/enable gitprompt by running:



RPM installation

This project includes an RPM specification to simplify installation on RHEL and clones. If you want to install from RPM, you can first compile the RPM from scratch by doing

the following:

  • Clone this repository and tag

the version with a version number

  • Run the following command to create a tarball


  • Log in to a RHEL host or clones and run:

You can then publish or install the rpm from “~/rpmbuild/RPMS/noarch”.


This code is licensed under the BSD 2 Clause (NetBSD) license.

Who are you?

The current maintainer of the original bash-git-prompt is Martin Gondermann.


If you want to contribute, you can look for issues with the tag in play. Please leave a comment about the problem, you want to fix it, so others know, the tags are “taken”.

Pull requests are welcome. I will review them and merge them, if I think they help the project.

Similar projects


I accept tips through Flattr.