23 lines
651 B
Bash
23 lines
651 B
Bash
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=$''
|
|
|
|
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
|
|
}
|
|
|
|
PROMPT_COMMAND=__set_prompt
|
|
|
|
printf '\033[3 q'
|