mirror of
https://github.com/Cornelicorn/bullet-train.zsh.git
synced 2025-12-06 11:50:38 +01:00
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:
@@ -260,6 +260,23 @@ prompt_status() {
|
||||
[[ -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
|
||||
# Entry point
|
||||
@@ -281,4 +298,4 @@ build_prompt() {
|
||||
|
||||
PROMPT='
|
||||
%{%f%b%k%}$(build_prompt)
|
||||
%{${fg_bold[default]}%}\$ %{$reset_color%}'
|
||||
%{${fg_bold[default]}%}$(prompt_char) %{$reset_color%}'
|
||||
|
||||
Reference in New Issue
Block a user