Skip to content

Instantly share code, notes, and snippets.

@douglasmiller
Created December 29, 2020 18:26
Show Gist options
  • Save douglasmiller/42667a50dc63e32f0e948d61693d3810 to your computer and use it in GitHub Desktop.
Save douglasmiller/42667a50dc63e32f0e948d61693d3810 to your computer and use it in GitHub Desktop.
Multi-line bash prompt
if [ -f $HOME/.git-prompt.sh ]; then
# Outputs the current branch if in a git repository
source $HOME/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWCOLORHINTS=true
GIT_PS1_UNTRACKEDFILES=true
function get_color {
echo $ResetColor"\[\e["$1"\]"
}
# Color codes
# Black 0;30 Dark Gray 1;30
# Blue 0;34 Light Blue 1;34
# Green 0;32 Light Green 1;32
# Cyan 0;36 Light Cyan 1;36
# Red 0;31 Light Red 1;31
# Purple 0;35 Light Purple 1;35
# Brown 0;33 Yellow 1;33
# Light Gray 0;37 White 1;37
Reset_Color="\[\e[0m\]"
Frame_Color=$(get_color "0;34m")
User_Color=$(get_color "0;33m")
At_Color=$(get_color "1;30m")
Git_Color=$(get_color "1;36m")
Path_Color=$(get_color "1;33m")
UID_Color=$(get_color "1;37m")
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
SSH_Color="\e[101m"
fi
PROMPT_COMMAND="__git_ps1 '\n\[\e[0;34m\]┌[$User_Color\u@$SSH_Color\h$Frame_Color]─[$Path_Color\w$Frame_Color]─[$Git_Color' '$Frame_Color]\n\[\e[0;34m\]└[$UID_Color\$$Frame_Color]› $Reset_Color' '%s'"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment