Add user prompt character options

Add two new user options for changing the final prompt character (default '$')
1) 'BULLETTRAIN_PROMPT_ROOT' - allow the user to choose if they want the final prompt character to change to '#' for root user.
2) 'BULLETTRAIN_PROMPT_CHAR' - allow the user to choose their own final prompt character (instead of '$') as long as it's length is a single character

This also changes the color of the prompt character, red for root, green for normal user, and could be expanded in the future for user selectable color choices.
This commit is contained in:
Jocelyn Mallon
2014-07-16 10:29:14 -07:00
parent 56f75cbda8
commit 6f7561eeb1

View File

@@ -260,6 +260,23 @@ prompt_status() {
[[ -n "$symbols" ]] && prompt_segment $BULLETTRAIN_STATUS_BG $BULLETTRAIN_STATUS_FG "$symbols" [[ -n "$symbols" ]] && prompt_segment $BULLETTRAIN_STATUS_BG $BULLETTRAIN_STATUS_FG "$symbols"
} }
# Prompt Character:
# should we show a basic '$' char
# or colored (red/green) different
# chars for root/normal prompt?
prompt_char() {
local bt_prompt_char
if [[ ${#BULLETTRAIN_PROMPT_CHAR} -eq 1 ]] then
bt_prompt_char="${BULLETTRAIN_PROMPT_CHAR}"
else
bt_prompt_char="\$"
fi
if [[ $BULLETTRAIN_PROMPT_ROOT == true ]] then
bt_prompt_char="%(!.%F{red}#.%F{green}${bt_prompt_char})"
fi
echo -n $bt_prompt_char
}
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# MAIN # MAIN
# Entry point # Entry point
@@ -281,4 +298,4 @@ build_prompt() {
PROMPT=' PROMPT='
%{%f%b%k%}$(build_prompt) %{%f%b%k%}$(build_prompt)
%{${fg_bold[default]}%}\$ %{$reset_color%}' %{${fg_bold[default]}%}$(prompt_char) %{$reset_color%}'