Home > git-ps1

git-ps1

Git-ps1 is a project mainly written in Shell, based on the GPL-3.0 license.

git-augmented PS1 for BASH

git-ps1 - git-augmented PS1 for BASH

SETUP

To use, modify your PS1 variable (e.g. in ~/.bashrc) to include the script: PS1="$PS1\$($( cat git-ps1.sh ))"

This script produces output in a number of different colors. To ensure the prompt operates correctly, non-printable characters must be escaped ([]). However, these characters are not recognized when output from an external script. Therefore, the script must be inserted directly into the PS1 string, where echoing the escape sequence will produce the intended result.

CONFIGURATION

All configuration is done via GITPS1_* environment variables.

Indicators (set to '0' to disable) GITPS1_IND_STAGED - Staged changes GITPS1_IND_UNSTAGED - Unstaged changes GITPS1_IND_UNTRACKED - Untracked files GITPS1_IND_AHEAD - Ahead of tracking branch GITPS1_IND_AHEAD_COUNT - Whether to display number of commits ahead (e.g. @5)

Colors: GITPS1_COLOR_DEFAULT - Default color, used to display brackets and branch GITPS1_COLOR_FASTFWD - Color used for fast-forward indicator and used to display brackets and hash when not on a branch GITPS1_COLOR_STAGED - Color used to for staged changes indicator GITPS1_COLOR_UNTRACKED - Color used for untracked files indicator GITPS1_COLOR_UNSTAGED - Color used for unstaged changes indicator GITPS1_COLOR_AHEAD - Color used for ahead indicator (ahead of tracking)