28 lines
No EOL
736 B
Bash
28 lines
No EOL
736 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 parse_git_branch() {
|
|
# git branch --show-current 2>/dev/null | sed 's/^/ (/' | sed 's/$/)/'
|
|
|
|
local branch
|
|
branch=$(git branch --show-current 2>/dev/null)
|
|
#[[ -n "$branch" ]] && printf ' \033[44;30m %s \033[0;34m\ue0b0\033[0m' "$branch"
|
|
|
|
if [[ -n "$branch" ]]; then
|
|
printf '\033[44;33m'$'\ue0b0''\033[44;30m %s \033[0;34m'$'\ue0b0''\033[0m' "$branch"
|
|
else
|
|
printf '\033[0;33m'$'\ue0b0''\033[0m'
|
|
fi
|
|
}
|
|
|
|
if [ "$color_prompt" = yes ]; then
|
|
PS1='\[\033[43;30m\] \w \[$(parse_git_branch)\] '
|
|
else
|
|
PS1='\w\$ '
|
|
fi
|
|
|
|
unset color_prompt
|
|
|
|
printf '\033[3 q' |