Skip to content

Instantly share code, notes, and snippets.

@bradwilson
Last active July 3, 2019 15:17
Show Gist options
  • Save bradwilson/7631d87b56c7e7071c6d to your computer and use it in GitHub Desktop.
Save bradwilson/7631d87b56c7e7071c6d to your computer and use it in GitHub Desktop.
bash-git prompt overrides

The OS X version does not require any custom fonts, because it uses the built-in emoji and symbol support in OS X.

The Linux version requires that you install Font Awesome.

# Assuming you "git clone'd" bash-git-prompt, add the following three lines to your .bashrc:
#
# source ~/.bash-git-prompt/gitprompt.sh
# source ~/.bash-git-prompt/prompt-colors.sh
# source ~/.git-prompt-overrides-linux.sh
Time12a="\$(date +%H:%M)"
# Configuration
GIT_PROMPT_SHOW_UNTRACKED_FILES="all"
GIT_PROMPT_IGNORE_STASH="1"
# Pre- and post-status prompt strings
GIT_PROMPT_COMMAND_FAIL="${ResetColor} ${RedBg}${BrightWhite} ✘-_LAST_COMMAND_STATE_ ${ResetColor}"
GIT_PROMPT_COMMAND_OK=""
GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_"
GIT_PROMPT_START_ROOT="${GIT_PROMPT_START_ROOT}"
GIT_PROMPT_END_USER="${ResetColor} ${BoldWhite}${Time12a}${BoldGreen} $ ${ResetColor}"
GIT_PROMPT_END_ROOT="${ResetColor} ${BoldWhite}${Time12a}${BoldRed} # ${ResetColor}"
# Individual overrides
GIT_PROMPT_BRANCH="${DimBlueBg}${BoldWhite}"
GIT_PROMPT_CHANGED="${DimBlueBg}${BoldYellow} ~"
GIT_PROMPT_CLEAN=""
GIT_PROMPT_CONFLICTS="${DimBlueBg}${BoldRed} ×"
GIT_PROMPT_PREFIX="${DimBlueBg}${BrightWhite}  "
GIT_PROMPT_REMOTE="${DimBlueBg}"
GIT_PROMPT_SEPARATOR=""
GIT_PROMPT_STAGED="${DimBlueBg}${BoldGreen} ±"
GIT_PROMPT_SUFFIX="${DimBlueBg}${DimBlueBg} "
GIT_PROMPT_UNTRACKED="${DimBlueBg}${BoldYellow} +"
GIT_PROMPT_VIRTUALENV=" ${DimGreenBg}${BoldWhite} _VIRTUALENV_ ${ResetColor}"
# Symbols
GIT_PROMPT_SYMBOLS_AHEAD="${BoldBlue}  "
GIT_PROMPT_SYMBOLS_BEHIND="${BoldBlue}  "
GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING="${DimBlueBg}${BoldBlue} ⁜ ${ResetColor}"
GIT_PROMPT_SYMBOLS_PREHASH=":"
# Assuming you used Homebrew to install bash-git-prompt, add the following three lines to your .bash_profile:
#
# source "$(brew --prefix bash-git-prompt)/share/gitprompt.sh"
# source "$(brew --prefix bash-git-prompt)/share/prompt-colors.sh"
# source ~/.git-prompt-overrides-mac.sh
Time12a="\$(date +%H:%M)"
# Configuration
GIT_PROMPT_SHOW_UNTRACKED_FILES="all"
GIT_PROMPT_IGNORE_STASH="1"
# Pre- and post-status prompt strings
GIT_PROMPT_COMMAND_FAIL="${ResetColor} ${RedBg}${BrightWhite} ✘-_LAST_COMMAND_STATE_ ${ResetColor}"
GIT_PROMPT_COMMAND_OK=""
GIT_PROMPT_START_USER="${ResetColor}${BoldYellow}_LAST_COMMAND_INDICATOR_"
GIT_PROMPT_START_ROOT="${GIT_PROMPT_START_USER}"
GIT_PROMPT_END_USER="${ResetColor} ${BoldWhite}${Time12a}${BoldGreen} $ ${ResetColor}"
GIT_PROMPT_END_ROOT="${ResetColor} ${BoldWhite}${Time12a}${BoldRed} # ${ResetColor}"
# Individual overrides
GIT_PROMPT_BRANCH="${BlueBg}${BoldWhite}"
GIT_PROMPT_CHANGED="${BlueBg}${BoldYellow} ~"
GIT_PROMPT_CLEAN=""
GIT_PROMPT_CONFLICTS="${BlueBg}${BoldRed} ⊗ "
GIT_PROMPT_PREFIX="${BlueBg}${BrightWhite} 🔑  "
GIT_PROMPT_REMOTE="${BlueBg}"
GIT_PROMPT_SEPARATOR=""
GIT_PROMPT_STAGED="${BlueBg}${BoldGreen} ±"
GIT_PROMPT_SUFFIX="${BlueBg}${DimBlueBg} ${ResetColor}"
GIT_PROMPT_UNTRACKED="${BlueBg}${BoldYellow} +"
GIT_PROMPT_VIRTUALENV=" ${GreenBg}${BoldWhite} 📦 _VIRTUALENV_ ${ResetColor}"
# Symbols
GIT_PROMPT_SYMBOLS_AHEAD="${BoldBlue} △ "
GIT_PROMPT_SYMBOLS_BEHIND="${BoldBlue} ▽ "
GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING="${BlueBg}${BoldBlue} ※"
GIT_PROMPT_SYMBOLS_PREHASH=":"
@bradwilson
Copy link
Author

This is what the symbols should look like if the Font Awesome font is installed:

fa-icons

You should substitute other symbols if you don't want to install the Font Awesome font (or are having trouble with the font fallback).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment