overhaul prompt management; make it easier to add/remove things to {,r}prompt over time

This commit is contained in:
2023-06-30 17:05:18 -07:00
parent ed5afe0300
commit 798ced71aa
5 changed files with 51 additions and 11 deletions

View File

@@ -4,4 +4,4 @@ function precmd_tab_directory () {
print -Pn "\e]0;%n@%m: %~\a"
}
precmd_functions+="precmd_tab_directory"
precmd_functions+="precmd_tab_directory"

24
base/prompt.zsh Normal file
View File

@@ -0,0 +1,24 @@
typeset -ag prompt_functions
typeset -ag rprompt_functions
function prompt_builder () {
result=""
for prompt_func in $prompt_functions; do
result="${result}$($prompt_func) "
done
# prompt will always end with "% " (or "# " if we're somehow root)
result="${result}%#%{$reset_color%} "
print "${result}"
}
function rprompt_builder () {
result=""
for rprompt_func in $rprompt_functions; do
result="$($rprompt_func) ${result}"
done
result="${result}%{$reset_color%}"
print "${result}"
}
PROMPT='$(prompt_builder)'
RPROMPT='$(rprompt_builder)'