diff options
Diffstat (limited to 'Functions')
-rw-r--r-- | Functions/Prompts/.distfiles | 9 | ||||
-rw-r--r-- | Functions/Prompts/prompt_adam2_setup | 11 | ||||
-rw-r--r-- | Functions/Prompts/prompt_fire_setup | 2 | ||||
-rw-r--r-- | Functions/Prompts/promptinit | 49 |
4 files changed, 43 insertions, 28 deletions
diff --git a/Functions/Prompts/.distfiles b/Functions/Prompts/.distfiles index 2c8ff8497..1a4310aa8 100644 --- a/Functions/Prompts/.distfiles +++ b/Functions/Prompts/.distfiles @@ -1,9 +1,8 @@ DISTFILES_SRC=' .distfiles - prompt_elite2_setup prompt_red_setup prompt_adam1_setup + prompt_elite2_setup prompt_adam1_setup prompt_fade_setup prompt_elite_setup prompt_redhat_setup prompt_adam2_setup - prompt_fire_setup prompt_suse_setup prompt_blue_setup - prompt_green_setup prompt_white_setup prompt_combo_setup - prompt_magenta_setup prompt_yellow_setup prompt_cyan_setup - prompt_oliver_setup prompt_off_setup promptinit + prompt_fire_setup prompt_suse_setup prompt_bigfade_setup + prompt_oliver_setup prompt_off_setup prompt_zefram_setup + promptinit ' diff --git a/Functions/Prompts/prompt_adam2_setup b/Functions/Prompts/prompt_adam2_setup index 7bac0854d..626ad431f 100644 --- a/Functions/Prompts/prompt_adam2_setup +++ b/Functions/Prompts/prompt_adam2_setup @@ -46,20 +46,17 @@ prompt_adam2_setup () { # This is a cute hack. Well I like it, anyway. prompt_gfx_bbox_to_mbox=$(print -n "%{\e[A\r$fg_bold[$prompt_adam2_color1]${prompt_gfx_mlc}$fg_no_bold[$prompt_adam2_color1]${prompt_gfx_hyphen}\e[B%}") - prompt_l_paren=$'%{$fg_bold[grey]%}(' - prompt_r_paren=$'%{$fg_bold[grey]%})' - - prompt_l_bracket=$'%{$fg_bold[grey]%}[' - prompt_r_bracket=$'%{$fg_bold[grey]%}]' + prompt_l_paren="%{$fg_bold[grey]%}(" + prompt_r_paren="%{$fg_bold[grey]%})" prompt_machine="%{$fg_no_bold[$prompt_adam2_color3]%}%n%{$fg_bold[$prompt_adam2_color3]%}@%{$fg_no_bold[$prompt_adam2_color3]%}%m" prompt_padding_text=`perl -e "print qq{${prompt_gfx_hyphen}} x 200"` prompt_line_1a="$prompt_gfx_tbox$prompt_l_paren%{$fg_bold[$prompt_adam2_color2]%}%~$prompt_r_paren%{$fg_no_bold[$prompt_adam2_color1]%}" - prompt_line_1a_no_color=$(echo "$prompt_line_1a" | perl -pe "s/%{.*?%}//g") + prompt_line_1a_no_color=$(echo "$prompt_line_1a" | perl -pe 's/%{.*?%}//g') prompt_line_1b="$prompt_l_paren$prompt_machine$prompt_r_paren%{$fg_no_bold[$prompt_adam2_color1]%}${prompt_gfx_hyphen}" - prompt_line_1b_no_color=$(echo "$prompt_line_1b" | perl -pe "s/%{.*?%}//g") + prompt_line_1b_no_color=$(echo "$prompt_line_1b" | perl -pe 's/%{.*?%}//g') prompt_line_2="$prompt_gfx_bbox${prompt_gfx_hyphen}%{$fg_bold[white]%}" diff --git a/Functions/Prompts/prompt_fire_setup b/Functions/Prompts/prompt_fire_setup index 1bf72531f..bb52fdfb7 100644 --- a/Functions/Prompts/prompt_fire_setup +++ b/Functions/Prompts/prompt_fire_setup @@ -43,7 +43,7 @@ prompt_fire_setup () { local COLOR6="%{$bold_color$fg[$date]$bg[grey]%}" local GRAD0="%{$reset_color%}" - PS1=$COLOR1$GRAD1$COLOR2'%n@%m'$COLOR3$GRAD2$COLOR4$GRAD1$COLOR6' %D{%a %b %d} %D{%I:%M:%S%P} '$NONE'$prompt_newline'$COLOR5'%~/'$GRAD0' ' + PS1=$COLOR1$GRAD1$COLOR2'%n@%m'$COLOR3$GRAD2$COLOR4$GRAD1$COLOR6' %D{%a %b %d} %D{%I:%M:%S%P} '$NONE$prompt_newline$COLOR5'%~/'$GRAD0' ' PS2=$COLOR1$GRAD1$COLOR3$GRAD2$COLOR4$GRAD1$COLOR5'>'$GRAD0' ' precmd () { setopt promptsubst } diff --git a/Functions/Prompts/promptinit b/Functions/Prompts/promptinit index 2786f9ac7..cfab990df 100644 --- a/Functions/Prompts/promptinit +++ b/Functions/Prompts/promptinit @@ -81,10 +81,11 @@ Use prompt -h <theme> for help on specific themes.' print $prompt_themes return ;; - p) if (( ! $+prompt_theme )); then - print "Cannot preview; current prompt is non-themeable and would" - print "be destroyed." - return + p) if [[ -z "$prompt_theme[1]" ]]; then + # Not using a prompt theme; save settings + prompt_non_theme=( "$PS1" "$PS2" "$PS3" "$PS4" "$RPS1" ) + prompt_old_precmd="$(functions precmd)" + prompt_old_preexec="$(functions preexec)" fi preview=( $prompt_themes ) (( $#* > 1 )) && preview=( "$@[2,-1]" ) @@ -97,10 +98,10 @@ Use prompt -h <theme> for help on specific themes.' fi print - # The next line is a bit ugly. It (perhaps unnecessarily) - # runs the prompt theme setup function to ensure that if - # the theme has a _preview function that it's been autoloaded. - prompt_${theme_args[1]}_setup + # The next line is a bit ugly. It (perhaps unnecessarily) + # runs the prompt theme setup function to ensure that if + # the theme has a _preview function that it's been autoloaded. + prompt_${theme_args[1]}_setup if functions prompt_${theme_args[1]}_preview >&/dev/null; then prompt_${theme_args[1]}_preview "${(@)theme_args[2,-1]}" @@ -109,7 +110,25 @@ Use prompt -h <theme> for help on specific themes.' fi done print - prompt_${prompt_theme[1]}_setup "${(@)prompt_theme[2,-1]}" + if [[ -z "$prompt_theme[1]" ]]; then + PS1="$prompt_non_theme[1]" + PS2="$prompt_non_theme[2]" + PS3="$prompt_non_theme[3]" + PS4="$prompt_non_theme[4]" + RPS1="$prompt_non_theme[5]" + if [[ -z "$prompt_old_precmd" ]]; then + precmd () { } + else + eval "$prompt_old_precmd" + fi + if [[ -z "$prompt_old_preexec" ]]; then + preexec () { } + else + eval "$prompt_old_preexec" + fi + else + prompt_${prompt_theme[1]}_setup "${(@)prompt_theme[2,-1]}" + fi ;; s) print "Set and save not yet implemented. Please ensure your ~/.zshrc" print "contains something similar to the following:\n" @@ -118,12 +137,12 @@ Use prompt -h <theme> for help on specific themes.' print " prompt $*[2,-1]" ;; *) if [[ "$1" == 'random' ]]; then - local random_themes - if (( $#* == 1 )); then - random_themes=( $prompt_themes ) - else - random_themes=( "$@[2,-1]" ) - fi + local random_themes + if (( $#* == 1 )); then + random_themes=( $prompt_themes ) + else + random_themes=( "$@[2,-1]" ) + fi local i=$(( ( $RANDOM % $#random_themes ) + 1 )) argv=( "${=random_themes[$i]}" ) fi |