Skip to content
This repository

Addon script to provide a short git prompt info to a bash prompt

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 README
Octocat-spinner-32 git_prompt.sh
Octocat-spinner-32 git_remote_check.sh
README
Bash Git Prompt

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

Preferred Installation Method

Clone the repository into your home directory.

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

source $HOME/Bash-Git-Prompt/git_remote_check.sh
source $HOME/Bash-Git-Prompt/git_prompt.sh

For Mac OS X: By default a .profile file does not exist in the home directory.
Create one using "touch ~/.profile" if it does not exist then add the same
two lines to it as for Linux:

source $HOME/Bash-Git-Prompt/git_remote_check.sh
source $HOME/Bash-Git-Prompt/git_prompt.sh

If remote tracking is not required then only add the following line to your
~/.bashrc or ~/.profile all the way at the bottom:

source $HOME/Bash-Git-Prompt/git_prompt.sh

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

Usage

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.
Tested on Mac OS X Lion.

Enjoy!
Something went wrong with that request. Please try again.