Addon script to provide a short git prompt info to a bash prompt
Switch branches/tags
Nothing to show
Pull request Compare This branch is 4 commits behind yerv000:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Bash Git Prompt

A Bash script to add git info to the shell prompt.

Preferred Installation Method

Clone the repository into your home directory.

Add the following lines to your ~/.bashrc file all the way at the bottom:

source $HOME/Bash-Git-Prompt/
source $HOME/Bash-Git-Prompt/

If in a terminal shell then exit and open a new shell.


Bash shell prompt will change to display repository information when a change directory is done into a git working tree.

The prompt will display various info, for example:

user@system(89m|master|?AM)(up to date)$

89m: Last commit was 89 minutes ago. Color will go from green to yellow to red
     depending on how long ago a commit was performed. Green<60m<Yellow<120m<Red
     If minutes span more than one day then the number of days are displayed as well.

master: On branch master

?AM: Git file flags. '?' for untracked files. 'A' for newly added uncommited files. 'M' for modified uncommited files.

(up to date) : local tracking branch is up to date with remote.

Remote check is done in the background after 5 minutes have passed since the last check and a carriage return is
hit in the bash shell. If a connection problem exists the user is notified.

To allow the background remote check a temporary file is created/deleted in /tmp directory.

Inside a git working tree use 'rd' to cd all the way to the root directory of the project.

Tested on Ubuntu 10.04.