dotfiles/.bash_prompt

34 lines
No EOL
870 B
Bash

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
function __set_prompt() {
local branch
branch=$(git branch --show-current 2>/dev/null)
# Colors (wrapped in \[ \] for proper length calculation)
local yellow_bg='\[\033[43;30m\]'
local blue_bg='\[\033[44;30m\]'
local yellow_on_blue='\[\033[44;33m\]'
local blue='\[\033[0;34m\]'
local yellow='\[\033[0;33m\]'
local reset='\[\033[0m\]'
local arrow=$'\ue0b0'
if [[ -n "$branch" ]]; then
PS1="${yellow_bg} \w ${yellow_on_blue}${arrow}${blue_bg} ${branch} ${blue}${arrow}${reset} "
else
PS1="${yellow_bg} \w ${yellow}${arrow}${reset} "
fi
}
if [ "$color_prompt" = yes ]; then
PROMPT_COMMAND=__set_prompt
else
PS1='\w\$ '
fi
unset color_prompt
printf '\033[3 q'