overhaul prompt management; make it easier to add/remove things to {,r}prompt over time
This commit is contained in:
		@@ -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
									
								
							
							
						
						
									
										24
									
								
								base/prompt.zsh
									
									
									
									
									
										Normal 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)'
 | 
			
		||||
		Reference in New Issue
	
	Block a user