A bash
script that displays information about the current git location. In particular the branch name, difference with remote branch, number of files staged, changed, etc.
This script is based on the original work of magicmonty (https://github.com/magicmonty/bash-git-prompt). In this fork I dropped a lot of stuff I didn't actually need, and modified the main behaviour: instead of setting your prompt, it outputs a colored string that you can include wherever you need.
The output of the script (included in a prompt) looks kinda like the following screenshot. In reality it is a bit outdated, but you get the idea :)
The symbols are as follows:
↑n
: ahead of remote byn
commits↓n
: behind remote byn
commits↓m↑n
: branches diverged, remote bym
commits, yours byn
commits✚n
: there aren
staged files●n
: there aren
unstaged files…n
: there aren
untracked files✖n
: there aren
unmerged files⚑n
: there aren
stash entries
Apply the following to ~/.bashrc
:
BLACK="\[\e[30m\]"
BLACK_HI="\[\e[90m\]"
RED="\[\e[31m\]"
RED_HI="\[\e[91m\]"
GREEN="\[\e[32m\]"
GREEN_HI="\[\e[92m\]"
BLUE="\[\e[34m\]"
BLUE_HI="\[\e[94m\]"
WHITE="\[\e[37m\]"
WHITE_HI="\[\e[97m\]"
RESET="\[\e[0m\]"
COLOR=${GREEN_HI}
BRACKETS=${BLACK_HI}
gitprompt="/path/to/your/bash-git-prompt/gitprompt.sh"
if [[ -f $gitprompt ]] ; then
export PS1="$BRACKETS\t $COLOR\u$BRACKETS:$WHITE_HI\w\$($gitprompt) $COLOR\$ $RESET"
else
export PS1="$BRACKETS\t $COLOR\u$BRACKETS:$WHITE_HI\w $COLOR\$ $RESET"
fi
This is my personal PS1 configuration, you can always configure it however you want it.