about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Misc/add-zsh-hook15
-rw-r--r--Functions/Prompts/prompt_adam1_setup15
-rw-r--r--Functions/Prompts/prompt_adam2_setup42
-rw-r--r--Functions/Prompts/prompt_bart_setup26
-rw-r--r--Functions/Prompts/prompt_bigfade_setup9
-rw-r--r--Functions/Prompts/prompt_clint_setup34
-rw-r--r--Functions/Prompts/prompt_elite2_setup17
-rw-r--r--Functions/Prompts/prompt_elite_setup7
-rw-r--r--Functions/Prompts/prompt_fade_setup9
-rw-r--r--Functions/Prompts/prompt_fire_setup23
-rw-r--r--Functions/Prompts/prompt_off_setup2
-rw-r--r--Functions/Prompts/prompt_oliver_setup10
-rw-r--r--Functions/Prompts/prompt_pws_setup22
-rw-r--r--Functions/Prompts/prompt_redhat_setup2
-rw-r--r--Functions/Prompts/prompt_special_chars19
-rw-r--r--Functions/Prompts/prompt_suse_setup2
-rw-r--r--Functions/Prompts/prompt_walters_setup3
-rw-r--r--Functions/Prompts/prompt_zefram_setup4
-rw-r--r--Functions/Prompts/promptinit37
19 files changed, 163 insertions, 135 deletions
diff --git a/Functions/Misc/add-zsh-hook b/Functions/Misc/add-zsh-hook
index b11db5b5c..d349ac635 100644
--- a/Functions/Misc/add-zsh-hook
+++ b/Functions/Misc/add-zsh-hook
@@ -4,6 +4,9 @@
 #
 # With -d, remove the function from the hook instead; delete the hook
 # variable if it is empty.
+# 
+# -D behaves like -d, but pattern characters are active in the
+# function name, so any matching function will be deleted from the hook.
 #
 # Without -d, the FUNCTION is marked for autoload; -U is passed down to
 # autoload if that is given.  (This is harmless if the function is actually
@@ -18,12 +21,16 @@ local opt
 local -a autoopts
 integer del
 
-while getopts "d" opt; do
+while getopts "dDU" opt; do
   case $opt in
     (d)
     del=1
     ;;
 
+    (D)
+    del=2
+    ;;
+
     (U)
     autoopts+=(-$opt)
     ;;
@@ -46,7 +53,11 @@ local fn="$2"
 if (( del )); then
   # delete, if hook is set
   if (( ${(P)+hook} )); then
-    set -A $hook ${(P)hook:#$fn}
+    if (( del == 2 )); then
+      set -A $hook ${(P)hook:#${~fn}}
+    else
+      set -A $hook ${(P)hook:#$fn}
+    fi
     # unset if no remaining entries --- this can give better
     # performance in some cases
     (( ${(P)#hook} )) || unset $hook
diff --git a/Functions/Prompts/prompt_adam1_setup b/Functions/Prompts/prompt_adam1_setup
index 19b7737eb..034641fb8 100644
--- a/Functions/Prompts/prompt_adam1_setup
+++ b/Functions/Prompts/prompt_adam1_setup
@@ -24,14 +24,13 @@ prompt_adam1_setup () {
   prompt_adam1_color2=${2:-'cyan'}
   prompt_adam1_color3=${3:-'green'}
 
-  base_prompt="%{$bg_no_bold[$prompt_adam1_color1]%}%n@%m%{$reset_color%} "
-  post_prompt="%{$reset_color%}"
+  base_prompt="%K{$prompt_adam1_color1}%n@%m%k "
+  post_prompt="%b%f%k"
 
-  base_prompt_no_color=$(echo "$base_prompt" | perl -pe "s/%{.*?%}//g")
-  post_prompt_no_color=$(echo "$post_prompt" | perl -pe "s/%{.*?%}//g")
+  base_prompt_no_color=$(echo "$base_prompt" | perl -pe "s/%(K{.*?}|k)//g")
+  post_prompt_no_color=$(echo "$post_prompt" | perl -pe "s/%(K{.*?}|k)//g")
 
-  precmd  () { prompt_adam1_precmd }
-  preexec () { }
+  add-zsh-hook precmd prompt_adam1_precmd
 }
 
 prompt_adam1_precmd () {
@@ -43,10 +42,10 @@ prompt_adam1_precmd () {
   base_prompt_etc=$(print -P "$base_prompt%(4~|...|)%3~")
   prompt_length=${#base_prompt_etc}
   if [[ $prompt_length -lt 40 ]]; then
-    path_prompt="%{$fg_bold[$prompt_adam1_color2]%}%(4~|...|)%3~%{$fg_bold[white]%}"
+    path_prompt="%B%F{$prompt_adam1_color2}%(4~|...|)%3~%F{white}"
   else
     space_left=$(( $COLUMNS - $#base_prompt_expanded_no_color - 2 ))
-    path_prompt="%{$fg_bold[$prompt_adam1_color3]%}%${space_left}<...<%~$prompt_newline%{$fg_bold_white%}"
+    path_prompt="%B%F{$prompt_adam1_color3}%${space_left}<...<%~$prompt_newline%F{white}"
   fi
   PS1="$base_prompt$path_prompt %# $post_prompt"
   PS2="$base_prompt$path_prompt %_> $post_prompt"
diff --git a/Functions/Prompts/prompt_adam2_setup b/Functions/Prompts/prompt_adam2_setup
index 612cb8958..14603b439 100644
--- a/Functions/Prompts/prompt_adam2_setup
+++ b/Functions/Prompts/prompt_adam2_setup
@@ -49,42 +49,44 @@ prompt_adam2_setup () {
   prompt_adam2_color4=${4:-'white'}   # user input
 
   local prompt_gfx_bbox 
-  prompt_gfx_tbox="%{$fg_bold[$prompt_adam2_color1]%}${prompt_gfx_tlc}%{$fg_no_bold[$prompt_adam2_color1]%}${prompt_gfx_hyphen}"
-  prompt_gfx_bbox="%{$fg_bold[$prompt_adam2_color1]%}${prompt_gfx_blc}${prompt_gfx_hyphen}%{$fg_no_bold[$prompt_adam2_color1]%}"
+  prompt_gfx_tbox="%B%F{$prompt_adam2_color1}${prompt_gfx_tlc}%b%F{$prompt_adam2_color1}${prompt_gfx_hyphen}"
+  prompt_gfx_bbox="%B%F{$prompt_adam2_color1}${prompt_gfx_blc}${prompt_gfx_hyphen}%b%F{$prompt_adam2_color1}"
 
   # This is a cute hack.  Well I like it, anyway.
-  prompt_gfx_bbox_to_mbox=$'%{\e[A\r'"$fg_bold[$prompt_adam2_color1]${prompt_gfx_mlc}$fg_no_bold[$prompt_adam2_color1]${prompt_gfx_hyphen}"$'\e[B%}'
+  prompt_gfx_bbox_to_mbox=$'%{\e[A\r'"%}%B%F{$prompt_adam2_color1}${prompt_gfx_mlc}%b%F{$prompt_adam2_color1}${prompt_gfx_hyphen}%{"$'\e[B%}'
 
-  prompt_l_paren="%{$fg_bold[grey]%}("
-  prompt_r_paren="%{$fg_bold[grey]%})"
+  prompt_l_paren="%B%F{black}("
+  prompt_r_paren="%B%F{black})"
 
-  prompt_user_host="%{$fg_no_bold[$prompt_adam2_color3]%}%n%{$fg_bold[$prompt_adam2_color3]%}@%{$fg_no_bold[$prompt_adam2_color3]%}%m"
+  prompt_user_host="%b%F{$prompt_adam2_color3}%n%B%F{$prompt_adam2_color3}@%b%F{$prompt_adam2_color3}%m"
 
-  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_1b="$prompt_l_paren$prompt_user_host$prompt_r_paren%{$fg_no_bold[$prompt_adam2_color1]%}${prompt_gfx_hyphen}"
+  prompt_line_1a="$prompt_gfx_tbox$prompt_l_paren%B%F{$prompt_adam2_color2}%~$prompt_r_paren%b%F{$prompt_adam2_color1}"
+  prompt_line_1b="$prompt_l_paren$prompt_user_host$prompt_r_paren%b%F{$prompt_adam2_color1}${prompt_gfx_hyphen}"
 
-  prompt_line_2="$prompt_gfx_bbox${prompt_gfx_hyphen}%{$fg_bold[white]%}"
+  prompt_line_2="$prompt_gfx_bbox${prompt_gfx_hyphen}%B%F{white}"
 
   prompt_char="%(!.#.>)"
 
-  precmd () { prompt_adam2_precmd; setopt promptsubst }
-  preexec () { prompt_adam2_preexec }
+  prompt_opts=(cr subst percent)
+
+  add-zsh-hook precmd prompt_adam2_precmd
 }
 
-prompt_adam2_precmd () {
+prompt_adam2_precmd() {
   setopt noxtrace localoptions extendedglob
   local prompt_line_1
 
   prompt_adam2_choose_prompt
 
-  PS1="$prompt_line_1$prompt_newline$prompt_line_2%{$fg_bold[white]%}$prompt_char %{$fg_bold[$prompt_adam2_color4]%}"
-  PS2="$prompt_line_2%{$prompt_gfx_bbox_to_mbox$fg_bold[white]%}%_> %{$fg_bold[$prompt_adam2_color4]%}"
-  PS3="$prompt_line_2%{$prompt_gfx_bbox_to_mbox$fg_bold[white]%}?# %{$fg_bold[$prompt_adam2_color4]%}"
+  PS1="$prompt_line_1$prompt_newline$prompt_line_2%B%F{white}$prompt_char %b%f%k"
+  PS2="$prompt_line_2$prompt_gfx_bbox_to_mbox%B%F{white}%_> %b%f%k"
+  PS3="$prompt_line_2$prompt_gfx_bbox_to_mbox%B%F{white}?# %b%f%k"
+  zle_highlight[(r)default:*]="default:fg=$prompt_adam2_color4,bold"
 }
 
 prompt_adam2_choose_prompt () {
-  local prompt_line_1a_width=${#${(S%%)prompt_line_1a//\%\{*\%\}}}
-  local prompt_line_1b_width=${#${(S%%)prompt_line_1b//\%\{*\%\}}}
+  local prompt_line_1a_width=${#${(S%%)prompt_line_1a//(\%([KF1]|)\{*\}|\%[Bbkf])}}
+  local prompt_line_1b_width=${#${(S%%)prompt_line_1b//(\%([KF1]|)\{*\}|\%[Bbkf])}}
 
   local prompt_padding_size=$(( COLUMNS
                                   - prompt_line_1a_width
@@ -110,11 +112,7 @@ prompt_adam2_choose_prompt () {
 
   # Still didn't fit; truncate 
   local prompt_pwd_size=$(( COLUMNS - 5 ))
-  prompt_line_1="$prompt_gfx_tbox$prompt_l_paren%{$fg_bold[$prompt_adam2_color2]%}%$prompt_pwd_size<...<%~%<<$prompt_r_paren%{$fg_no_bold[$prompt_adam2_color1]$prompt_gfx_hyphen%}"
-}
-
-prompt_adam2_preexec () {
-  print -n "$reset_color"
+  prompt_line_1="$prompt_gfx_tbox$prompt_l_paren%B%F{$prompt_adam2_color2}%$prompt_pwd_size<...<%~%<<$prompt_r_paren%b%F{$prompt_adam2_color1}$prompt_gfx_hyphen"
 }
 
 prompt_adam2_setup "$@"
diff --git a/Functions/Prompts/prompt_bart_setup b/Functions/Prompts/prompt_bart_setup
index e6b28a477..4489c0425 100644
--- a/Functions/Prompts/prompt_bart_setup
+++ b/Functions/Prompts/prompt_bart_setup
@@ -70,7 +70,7 @@ integer PSCOL=1
 
 prompt_bart_precmd () {
     setopt localoptions noxtrace noksharrays unset
-    local zero='%([BSUbsu]|{*%})' escape colno lineno
+    local zero='%([BSUbfksu]|FB{*})' escape colno lineno
 
     # Using psvar here protects against unwanted promptsubst expansions.
 
@@ -102,7 +102,7 @@ prompt_bart_ps1 () {
     setopt localoptions noxtrace noksharrays
 
     local -ah ps1
-    local -h host hist1 hist2 dir space date time rs="%{$reset_color%}"
+    local -h host hist1 hist2 dir space date time rs="%b%f%k"
     local -h eon="%(?.[.%20(?.[%U.%S[))" eoff="%(?.].%20(?.%u].]%s))"
 
     # Set up the components of the upper line
@@ -140,17 +140,19 @@ prompt_bart_winch () {
     setopt localoptions nolocaltraps noksharrays unset
 
     # Delete ourself from TRAPWINCH if not using our precmd insert.
-    [[ $functions[precmd] = *prompt_bart_precmd* ]] && prompt_bart_ps1 ||
+    [[ $precmd_functions = *prompt_bart_precmd* ]] && prompt_bart_ps1 ||
 	functions[TRAPWINCH]="${functions[TRAPWINCH]//prompt_bart_winch}"
 }
 
 prompt_bart_setup () {
     setopt localoptions nolocaltraps noksharrays unset
+    typeset -gA fg
 
     # A few extra niceties ...
     repeat 1 case "$1:l" in
       (off|disable)
-	functions[precmd]="${functions[precmd]//prompt_bart_precmd}"
+        precmd_functions[(r)prompt_*_precmd]=
+	precmd_functions=($precmd_functions)
 	functions[TRAPWINCH]="${functions[TRAPWINCH]//prompt_bart_winch}"
 	[[ $prompt_theme[1] = bart ]] && PS1=${${(f)PS1}[-1]}
 	return 1
@@ -161,22 +163,22 @@ prompt_bart_setup () {
 	;&
       (*)
 	# Abuse the fg assoc to hold our selected colors ...
-	fg[%m]=$fg[${1:-red}]
-	fg[%h]=$fg[${2:-blue}]
-	fg[%~]=$fg[${3:-none}]
-	fg[%D]=$fg[${4:-none}]
-	fg[%@]=$fg[${1:-red}]
+	fg[%m]="%F{${1:-red}}"
+	fg[%h]="%F{${2:-blue}}"
+	fg[%~]="%F{${3:-default}}"
+	fg[%D]="%F{${4:-default}}"
+	fg[%@]="%F{${1:-red}}"
 	;;
     esac
 
     prompt_bart_ps1
 
     # No RPS1 by default because prompt_off_setup doesn't fix it.
-    (($#RPS1 && $# > 4)) && RPS1="%{$fg[$5]%}$RPS1%{$reset_color%}"
+    (($#RPS1 && $# > 4)) && RPS1="%F{$5}$RPS1%f"
 
     # Paste our special commands into precmd and TRAPWINCH
-    functions[precmd]="${functions[precmd]//prompt_*_precmd}
-	prompt_bart_precmd"
+    
+    add-zsh-hook precmd prompt_bart_precmd
     functions[TRAPWINCH]="${functions[TRAPWINCH]//prompt_bart_winch}
 	prompt_bart_winch"
 
diff --git a/Functions/Prompts/prompt_bigfade_setup b/Functions/Prompts/prompt_bigfade_setup
index 89ae44981..733bfd406 100644
--- a/Functions/Prompts/prompt_bigfade_setup
+++ b/Functions/Prompts/prompt_bigfade_setup
@@ -27,15 +27,14 @@ prompt_bigfade_setup () {
   local date=${3:-'white'}
   local cwd=${4:-'yellow'}
 
-  local char_333 char_262 char_261 char_260
+  local -A schars
   autoload -U prompt_special_chars
   prompt_special_chars
 
-  PS1="%{$bold_color$fg[$fadebar]$bold_color%}$char_333$char_262$char_261$char_260%{$bold_color$fg[$userhost]$bg[$fadebar]%}%n@%m%{$reset_color$fg[$fadebar]$bg[grey]%}$char_260$char_261$char_262$char_333%{$reset_color$fg[$fadebar]$bg[grey]%}$char_333$char_262$char_261$char_260%{$bold_color$fg[$date]$bg[grey]%} %D{%a %b %d} %D{%I:%M:%S%P}$prompt_newline%{$bold_color$fg[$cwd]$bg[grey]%}$PWD>%{$reset_color%} "
-  PS2="%{$bold_color$fg[$fadebar]$bold_color%}$char_333$char_262$char_261$char_260%{$reset_color$fg[$fadebar]$bg[grey]%}$char_260$char_261$char_262$char_333%{$reset_color$fg[$fadebar]$bg[grey]%}$char_333$char_262$char_261$char_260%{$bold_color$bold_color$fg[$fadebar]%}>%{$reset_color%} "
+  PS1="%B%F{$fadebar}$schars[333]$schars[262]$schars[261]$schars[260]%B%F{$userhost}%K{$fadebar}%n@%m%b%k%f%F{$fadebar}%K{black}$schars[260]$schars[261]$schars[262]$schars[333]%b%f%k%F{$fadebar}%K{black}$schars[333]$schars[262]$schars[261]$schars[260]%B%F{$date}%K{black} %D{%a %b %d} %D{%I:%M:%S%P}$prompt_newline%B%F{$cwd}%K{black}$PWD>%b%f%k "
+  PS2="%B%F{$fadebar}$schars[333]$schars[262]$schars[261]$schars[260]%b%F{$fadebar}%K{black}$schars[260]$schars[261]$schars[262]$schars[333]%F{$fadebar}%K{black}$schars[333]$schars[262]$schars[261]$schars[260]%B%F{$fadebar}>%b%f%k "
 
-  precmd () { setopt promptsubst }
-  preexec () { }
+  prompt_opts=(cr subst percent)
 }
 
 prompt_bigfade_preview () {
diff --git a/Functions/Prompts/prompt_clint_setup b/Functions/Prompts/prompt_clint_setup
index a9960a016..154edede1 100644
--- a/Functions/Prompts/prompt_clint_setup
+++ b/Functions/Prompts/prompt_clint_setup
@@ -21,36 +21,35 @@ prompt_clint_setup () {
   pcc[4]=${4:-'yellow'}
   pcc[5]=${5:-'white'}
 
-  pc['\[']="%{$fg_no_bold[$pcc[1]]%}["
-  pc['\]']="%{$fg_no_bold[$pcc[1]]%}]"
-  pc['<']="%{$fg_no_bold[$pcc[1]]%}<"
-  pc['>']="%{$fg_no_bold[$pcc[1]]%}>"
-  pc['\(']="%{$fg_no_bold[$pcc[1]]%}("
-  pc['\)']="%{$fg_no_bold[$pcc[1]]%})"
+  pc['\[']="%F{$pcc[1]}["
+  pc['\]']="%F{$pcc[1]}]"
+  pc['<']="%F{$pcc[1]}<"
+  pc['>']="%F{$pcc[1]}>"
+  pc['\(']="%F{$pcc[1]}("
+  pc['\)']="%F{$pcc[1]})"
 
-  p_date="$pc['\[']%{$fg_no_bold[$pcc[2]]%}%D{%a %y/%m/%d %R %Z}$pc['\]']"
-  p_tty="$pc['\[']%{$fg_no_bold[$pcc[3]]%}%l$pc['\]']"
-  p_plat="$pc['\[']%{$fg_no_bold[$pcc[2]]%}${MACHTYPE}/${OSTYPE}/$(uname -r)$pc['\]']"
-  p_ver="$pc['\[']%{$fg_no_bold[$pcc[2]]%}${ZSH_VERSION}$pc['\]']"
+  p_date="$pc['\[']%F{$pcc[2]}%D{%a %y/%m/%d %R %Z}$pc['\]']"
+  p_tty="$pc['\[']%F{$pcc[3]}%l$pc['\]']"
+  p_plat="$pc['\[']%F{$pcc[2]}${MACHTYPE}/${OSTYPE}/$(uname -r)$pc['\]']"
+  p_ver="$pc['\[']%F{$pcc[2]}${ZSH_VERSION}$pc['\]']"
 
-  [[ -n "$WINDOW" ]] && p_win="$pc['\(']%{$fg_bold[$pcc[4]]%}$WINDOW$pc['\)']"
+  [[ -n "$WINDOW" ]] && p_win="$pc['\(']%F{$pcc[4]}$WINDOW$pc['\)']"
 
-  p_userpwd="$pc['<']%{$fg_no_bold[$pcc[3]]%}%n@%m$p_win%{$fg_bold[$pcc[5]]%}:%{$fg_no_bold[$pcc[4]]%}%~$pc['>']"
+  p_userpwd="$pc['<']%F{$pcc[3]}%n@%m$p_win%F{$pcc[5]}:%F{$pcc[4]}%~$pc['>']"
   p_git="%(2v.-%U%2v%u-.)"
 
-  p_shlvlhist="%{$reset_color%}zsh%(2L./$SHLVL.) %B%h%b "
+  p_shlvlhist="%fzsh%(2L./$SHLVL.) %B%h%b "
   p_rc="%(?..[%?%1v] )"
-  p_end="%{$reset_color%}%B%#%b %{$fg_no_bold[$pcc[2]]%}"
+  p_end="%f%B%#%b "
 
-  POSTEDIT="$reset_color"
+  zle_highlight[(r)default:*]=default:$pcc[2]
 
   prompt="$p_date$p_tty$p_plat$p_ver
 $p_userpwd
 $p_shlvlhist$p_rc$p_git$p_end"
   PS2='%(4_.\.)%3_> %E'
 
-  precmd () { prompt_clint_precmd }
-  preexec () { }
+  add-zsh-hook precmd prompt_clint_precmd
 }
 
 prompt_clint_precmd () {
@@ -67,7 +66,6 @@ prompt_clint_precmd () {
   git_dir=$(git-rev-parse --git-dir 2> /dev/null) || return
   git_ref=$(git-symbolic-ref HEAD 2> /dev/null) || git_ref="(no branch)"
   psvar[2]=${git_ref#refs/heads/}
-
 }
 
 prompt_clint_setup "$@"
diff --git a/Functions/Prompts/prompt_elite2_setup b/Functions/Prompts/prompt_elite2_setup
index 0c1500a16..68de21cc5 100644
--- a/Functions/Prompts/prompt_elite2_setup
+++ b/Functions/Prompts/prompt_elite2_setup
@@ -21,24 +21,23 @@ prompt_elite2_setup () {
   local text_col=${1:-'cyan'}
   local parens_col=${2:-$text_col}
 
-  local char_333 char_262 char_261 char_260
+  local -A schars
   autoload -U prompt_special_chars
   prompt_special_chars
 
-  local text="%{$fg_no_bold[$text_col]%}"
-  local parens="%{$fg_bold[$parens_col]%}"
-  local punct="%{$fg_bold[grey]%}"
-  local reset="%{$reset_color%}"
+  local text="%b%F{$text_col}"
+  local parens="%B%F{$parens_col}"
+  local punct="%B%F{black}"
+  local reset="%b%f"
 
   local lpar="$parens($text"
   local rpar="$parens)$text"
 
-  PS1="$punct$char_332$text$char_304$lpar%n$punct@$text%m$rpar$char_304$lpar%!$punct/$text%y$rpar$char_304$lpar%D{%I:%M%P}$punct:$text%D{%m/%d/%y}$rpar$char_304$punct-$reset$prompt_newline$punct$char_300$text$char_304$lpar%#$punct:$text%~$rpar$char_304$punct-$reset " 
+  PS1="$punct$schars[332]$text$schars[304]$lpar%n$punct@$text%m$rpar$schars[304]$lpar%!$punct/$text%y$rpar$schars[304]$lpar%D{%I:%M%P}$punct:$text%D{%m/%d/%y}$rpar$schars[304]$punct-$reset$prompt_newline$punct$schars[300]$text$schars[304]$lpar%#$punct:$text%~$rpar$schars[304]$punct-$reset " 
 
-  PS2="$parens$char_304$text$char_304$punct-$reset "
+  PS2="$parens$schars[304]$text$schars[304]$punct-$reset "
 
-  precmd () { setopt promptsubst }
-  preexec () { }
+  prompt_opts=(cr subst percent)
 }
 
 prompt_elite2_preview () {
diff --git a/Functions/Prompts/prompt_elite_setup b/Functions/Prompts/prompt_elite_setup
index 89e9bffdf..7af45dd88 100644
--- a/Functions/Prompts/prompt_elite_setup
+++ b/Functions/Prompts/prompt_elite_setup
@@ -21,15 +21,14 @@ prompt_elite_setup () {
   local text=${1:-'red'}
   local punctuation=${2:-'blue'}
 
-  local char_333 char_262 char_261 char_260
+  local -A schars
   autoload -U prompt_special_chars
   prompt_special_chars
 
-  PS1="%{$fg[$text]%}$char_332$char_304%{$fg[$punctuation]%}(%{$fg[$text]%}%n%{$fg[$punctuation]%}@%{$fg[$text]%}%m%{$fg[$punctuation]%})%{$fg[$text]%}-%{$fg[$punctuation]%}(%{$fg[$text]%}%D{%I:%M%P}%{$fg[$punctuation]%}-:-%{$fg[$text]%}%D{%m}%{$fg[$punctuation]$fg[$text]%}/%D{%d}%{$fg[$punctuation]%})%{$fg[$text]%}$char_304-%{$fg[$punctuation]]%}$char_371%{$fg[$text]%}-$char_371$char_371%{$fg[$punctuation]%}$char_372$prompt_newline%{$fg[$text]%}$char_300$char_304%{$fg[$punctuation]%}(%{$fg[$text]%}%1~%{$fg[$punctuation]%})%{$fg[$text]%}$char_304$char_371%{$fg[$punctuation]%}$char_372%{$reset_color%}"
+  PS1="%F{$text}$schars[332]$schars[304]%F{$punctuation}(%F{$text}%n%F{$punctuation}@%F{$text}%m%F{$punctuation})%F{$text}-%F{$punctuation}(%F{$text}%D{%I:%M%P}%F{$punctuation}-:-%F{$text}%D{%m}%F{$punctuation}%F{$text}/%D{%d}%F{$punctuation})%F{$text}$schars[304]-%F{$punctuation}$schars[371]%F{$text}-$schars[371]$schars[371]%F{$punctuation}$schars[372]$prompt_newline%F{$text}$schars[300]$schars[304]%F{$punctuation}(%F{$text}%1~%F{$punctuation})%F{$text}$schars[304]$schars[371]%F{$punctuation}$schars[372]%f"
   PS2="> "
 
-  precmd () { setopt promptsubst }
-  preexec () { }
+  prompt_opts=(cr subst percent)
 }
 
 prompt_elite_preview () {
diff --git a/Functions/Prompts/prompt_fade_setup b/Functions/Prompts/prompt_fade_setup
index 10b27f164..6d43f723d 100644
--- a/Functions/Prompts/prompt_fade_setup
+++ b/Functions/Prompts/prompt_fade_setup
@@ -27,15 +27,14 @@ prompt_fade_setup () {
   local userhost=${2:-'white'}
   local date=${3:-'white'}
 
-  local char_333 char_262 char_261 char_260
+  local -A schars
   autoload -U prompt_special_chars
   prompt_special_chars
 
-  PS1="%{$fg[$fadebar_cwd]$bg[$fadebar_cwd]$bold_color%}$char_333$char_262$char_261$char_260%{$fg[$userhost]$bg[$fadebar_cwd]$bold_color%}%n@%m%{$reset_color$fg[$fadebar_cwd]$bg[grey]%}$char_333$char_262$char_261$char_260%{$fg[$date]$bg[grey]$bold_color%} %D{%a %b %d} %D{%I:%M:%S%P} $prompt_newline%{$fg[$fadebar_cwd]$bg[grey]$bold_color%}%~/%{$reset_color%} "
-  PS2="%{$fg[$fadebar_cwd]$bg[grey]%}$char_333$char_262$char_261$char_260%{$reset_color%}>"
+  PS1="%F{$fadebar_cwd}%B%K{$fadebar_cwd}$schars[333]$schars[262]$schars[261]$schars[260]%F{$userhost}%K{$fadebar_cwd}%B%n@%m%b%F{$fadebar_cwd}%K{black}$schars[333]$schars[262]$schars[261]$schars[260]%F{$date}%K{black}%B %D{%a %b %d} %D{%I:%M:%S%P} $prompt_newline%F{fadebar_cwd}%K{black}%B%~/%b%k%f "
+  PS2="%F{$fadebar_cwd}%K{black}$schars[333]$schars[262]$schars[261]$schars[260]%f%k>"
 
-  precmd () { setopt promptsubst }
-  preexec () { }
+  prompt_opts=(cr subst percent)
 }
 
 prompt_fade_preview () {
diff --git a/Functions/Prompts/prompt_fire_setup b/Functions/Prompts/prompt_fire_setup
index 039e41e4a..7043fd456 100644
--- a/Functions/Prompts/prompt_fire_setup
+++ b/Functions/Prompts/prompt_fire_setup
@@ -29,25 +29,24 @@ prompt_fire_setup () {
   local date=${5:-'white'}
   local cwd=${6:-'yellow'}
 
-  local char_333 char_262 char_261 char_260
+  local -a schars
   autoload -U prompt_special_chars
   prompt_special_chars
 
-  local GRAD1="%{$char_333$char_262$char_261$char_260%}"
-  local GRAD2="%{$char_260$char_261$char_262$char_333%}"
-  local COLOR1="%{$bold_color$fg[$fire1]$bg[$fire2]%}"
-  local COLOR2="%{$bold_color$fg[$userhost]$bg[$fire2]%}"
-  local COLOR3="%{$reset_color$fg[$fire3]$bg[$fire2]%}"
-  local COLOR4="%{$reset_color$fg[$fire3]$bg[grey]%}"
-  local COLOR5="%{$bold_color$fg[$cwd]$bg[grey]%}"
-  local COLOR6="%{$bold_color$fg[$date]$bg[grey]%}"
-  local GRAD0="%{$reset_color%}"
+  local GRAD1="%{$schars[333]$schars[262]$schars[261]$schars[260]%}"
+  local GRAD2="%{$schars[260]$schars[261]$schars[262]$schars[333]%}"
+  local COLOR1="%B%F{$fire1}%K{$fire2}"
+  local COLOR2="%B%F{$userhost}%K{$fire2}"
+  local COLOR3="%b%F{$fire3}%K{$fire2}"
+  local COLOR4="%b%F{$fire3}%K{black}"
+  local COLOR5="%B%F{$cwd}%K{black}"
+  local COLOR6="%B%F{$date}%K{black}"
+  local GRAD0="%b%f%k"
 
   PS1=$COLOR1$GRAD1$COLOR2'%n@%m'$COLOR3$GRAD2$COLOR4$GRAD1$COLOR6' %D{%a %b %d} %D{%I:%M:%S%P} '$prompt_newline$COLOR5'%~/'$GRAD0' '
   PS2=$COLOR1$GRAD1$COLOR3$GRAD2$COLOR4$GRAD1$COLOR5'>'$GRAD0' '
 
-  precmd () { setopt promptsubst }
-  preexec () { }
+  prompt_opts=(cr subst percent)
 }
 
 prompt_fire_preview () {
diff --git a/Functions/Prompts/prompt_off_setup b/Functions/Prompts/prompt_off_setup
index 6091f4894..f604b477f 100644
--- a/Functions/Prompts/prompt_off_setup
+++ b/Functions/Prompts/prompt_off_setup
@@ -4,8 +4,6 @@ prompt_off_setup () {
   PS2="> "
 
   prompt_opts=( cr percent )
-  precmd () { }
-  preexec () { }
 }
 
 prompt_off_setup "$@"
diff --git a/Functions/Prompts/prompt_oliver_setup b/Functions/Prompts/prompt_oliver_setup
index f7c4c7e5a..44d3f99ae 100644
--- a/Functions/Prompts/prompt_oliver_setup
+++ b/Functions/Prompts/prompt_oliver_setup
@@ -24,18 +24,18 @@ prompt_oliver_setup() {
   [[ "${(t)pcolour}" != assoc* ]] && typeset -Ag pcolour
   [[ "${(t)tcolour}" != assoc* ]] && typeset -Ag tcolour
   local pcol=${1:-${pcolour[${HOST:=`hostname`}]:-bold}}
-  local pcolr=$fg[${pcol#bold}]
+  local pcolr="%F{${${pcol#bold}:-default}}"
   [[ $pcol = bold* ]] && pcolr=%B$pcolr
-  
+
   local tcol=${2:-${tcolour[$HOST]}}
-  local tcolr="fg=${tcol#bold}"
+  local tcolr="fg=${${tcol#bold}:-default}"
   [[ $tcol = bold* ]] && tcolr=bold,$tcolr
-  
+
   local a host="%m:" user="%n "
   [[ $HOST == (${(j(|))~normal_hosts}) ]] && host=""
   [[ $LOGNAME == (root|${(j(|))~normal_users}) ]] && user=""
 
-  PS1="%{$pcolr%}$user$host%~%"'$((COLUMNS-12))'"(l.$prompt_newline. )[%h%1(j.%%%j.)%0(?..:%?)]%# %{$reset_color%}"  RPS2='<%^'
+  PS1="$pcolr$user$host%~%"'$((COLUMNS-12))'"(l.$prompt_newline. )[%h%1(j.%%%j.)%0(?..:%?)]%# %b%f%k"  RPS2='<%^'
   PS2=''
   zle_highlight[(r)default:*]=default:$tcolr
 }
diff --git a/Functions/Prompts/prompt_pws_setup b/Functions/Prompts/prompt_pws_setup
new file mode 100644
index 000000000..c9892141e
--- /dev/null
+++ b/Functions/Prompts/prompt_pws_setup
@@ -0,0 +1,22 @@
+# pws prompt theme
+
+prompt_pws_help() {
+    cat <<'EOF'
+Simple prompt which tries to display only the information you need.
+- highlighted parenthesised status if last command had non-zero status
+- bold + if shell is not at top level (may need tweaking if there
+  is another shell in the process history of your terminal)
+- number of background jobs in square brackets if non-zero
+- time in yellow on black, with Ding! on the hour.
+I usually use this in a white on black terminal.
+EOF
+}
+
+prompt_pws_setup() {
+      PS1='%K{white}%F{red}%(?..(%?%))'\
+'%K{black}%F{white}%B%(2L.+.)%(1j.[%j].)'\
+'%F{yellow}%(t.Ding!.%D{%L:%M})'\
+'%f%k%b%# '
+}
+
+prompt_pws_setup "$@"
diff --git a/Functions/Prompts/prompt_redhat_setup b/Functions/Prompts/prompt_redhat_setup
index 58e6bd698..5bde7f9ab 100644
--- a/Functions/Prompts/prompt_redhat_setup
+++ b/Functions/Prompts/prompt_redhat_setup
@@ -7,8 +7,6 @@ prompt_redhat_setup () {
   PS2="> "
 
   prompt_opts=( cr percent )
-  precmd () { }
-  preexec () { }
 }
 
 prompt_redhat_setup "$@"
diff --git a/Functions/Prompts/prompt_special_chars b/Functions/Prompts/prompt_special_chars
index 8be7dc1cf..3dbf481ff 100644
--- a/Functions/Prompts/prompt_special_chars
+++ b/Functions/Prompts/prompt_special_chars
@@ -6,13 +6,20 @@
 # We still provide them in that form if the current character
 # set isn't UTF-8.  We could in principle use iconv if available.
 
+typeset -gA schars
+
 if [[ ${LC_ALL:-${LC_CTYPE:-$LANG}} = *UTF-8* ]]; then
-  char_333=$'\xe2\x96\x88'
-  char_262=$'\xe2\x96\x93'
-  char_261=$'\xe2\x96\x92'
-  char_260=$'\xe2\x96\x91'
+  schars[300]=$'\xe2\x94\x94'
+  schars[304]=$'\xe2\x94\x8c'
+  schars[332]=$'\xe2\x94\x8c'
+  schars[333]=$'\xe2\x96\x88'
+  schars[371]=$'\xc2\xa8'
+  schars[372]=$'\xcb\x99'
+  schars[262]=$'\xe2\x96\x93'
+  schars[261]=$'\xe2\x96\x92'
+  schars[260]=$'\xe2\x96\x91'
 else
-  for code in 333 262 261 260; do
-    char_$code=$(echo -n "\\0$code")
+  for code in 300 304 332 333 371 372 262 261 260; do
+    eval "char[$code]=\$'\\$code'"
   done
 fi
diff --git a/Functions/Prompts/prompt_suse_setup b/Functions/Prompts/prompt_suse_setup
index 9b937be07..9cc4d31a5 100644
--- a/Functions/Prompts/prompt_suse_setup
+++ b/Functions/Prompts/prompt_suse_setup
@@ -7,8 +7,6 @@ prompt_suse_setup () {
   PS2="> "
 
   prompt_opts=( cr percent )
-  precmd () { }
-  preexec () { }
 }
 
 prompt_suse_setup "$@"
diff --git a/Functions/Prompts/prompt_walters_setup b/Functions/Prompts/prompt_walters_setup
index a0777f1bb..b2b0b8430 100644
--- a/Functions/Prompts/prompt_walters_setup
+++ b/Functions/Prompts/prompt_walters_setup
@@ -15,11 +15,12 @@ prompt_walters_setup () {
 
 if [[ "$TERM" != "dumb" ]]; then
     export PROMPT='%B%(?..[%?] )%b%n@%U%m%u> '
-    export RPROMPT="%{$fg_no_bold[${1:-green}]%}%~%{$reset_color%}"
+    export RPROMPT="%F{${1:-green}}%~%f"
 else
     export PROMPT="%(?..[%?] )%n@%m:%~> "
 fi
 
+  prompt_opts=(cr percent)
 }
 
 prompt_walters_setup "$@"
diff --git a/Functions/Prompts/prompt_zefram_setup b/Functions/Prompts/prompt_zefram_setup
index 7b7eefb28..a138a520b 100644
--- a/Functions/Prompts/prompt_zefram_setup
+++ b/Functions/Prompts/prompt_zefram_setup
@@ -12,8 +12,8 @@ function prompt_zefram_setup {
   PS2='%(4_:... :)%3_> '
 
   prompt_opts=( cr subst percent )
-  precmd () { prompt_zefram_precmd }
-  preexec () { }
+
+  add-zsh-hook precmd prompt_zefram_precmd
 }
 
 prompt_zefram_setup "$@"
diff --git a/Functions/Prompts/promptinit b/Functions/Prompts/promptinit
index df3d30649..f68191dd2 100644
--- a/Functions/Prompts/promptinit
+++ b/Functions/Prompts/promptinit
@@ -30,9 +30,8 @@ promptinit () {
     fi
   done
 
-  # Color definitions come in handy
-  autoload -U colors
-  colors
+  # To manipulate precmd and preexec hooks...
+  autoload -U add-zsh-hook
 
   # Variables common to all prompt styles
   prompt_newline=$'\n%{\r%}'
@@ -40,7 +39,7 @@ promptinit () {
 
 prompt_preview_safely() {
   emulate -L zsh
-  print $reset_color
+  print -P "%b%f%k"
   if [[ -z "$prompt_themes[(r)$1]" ]]; then
     print "Unknown theme: $1"
     return
@@ -48,7 +47,7 @@ prompt_preview_safely() {
 
   local -a psv; psv=($psvar); local -a +h psvar; psvar=($psv) # Ick
   local +h PS1=$PS1 PS2=$PS2 PS3=$PS3 PS4=$PS4 RPS1=$RPS1
-  trap "${$(functions precmd):-:} ; ${$(functions preexec):-:}" 0
+  local -a precmd_functions preexec_functions
 
   # The next line is a bit ugly.  It (perhaps unnecessarily)
   # runs the prompt theme setup function to ensure that if
@@ -85,7 +84,7 @@ Use prompt -h <theme> for help on specific themes.'
         # Not using a prompt theme; save settings
         local -a psv; psv=($psvar); local -a +h psvar; psvar=($psv) # Ick
 	local +h PS1=$PS1 PS2=$PS2 PS3=$PS3 PS4=$PS4 RPS1=$RPS1
-	trap "${$(functions precmd):-:} ; ${$(functions preexec):-:}" 0
+	local precmd_functions preexec_functions
       else
         trap 'prompt_${prompt_theme[1]}_setup "${(@)prompt_theme[2,-1]}"' 0
       fi
@@ -130,7 +129,7 @@ Use prompt -h <theme> for help on specific themes.'
          [[ "$theme" == "$prompt_theme[*]" ]] && continue
          prompt_preview_safely "$=theme"
        done
-       print $reset_color
+       print -P "%b%f%k"
        ;;
     s) print "Set and save not yet implemented.  Please ensure your ~/.zshrc"
        print "contains something similar to the following:\n"
@@ -153,21 +152,21 @@ Use prompt -h <theme> for help on specific themes.'
          print "$usage"
          return
        fi
-       prompt_$1_setup "$@[2,-1]" && prompt_theme=( "$@" )
 
-       # Avoid screwing up the environment listing
-       PSZZZZ=$reset_color
-       RPSZZZZ=$reset_color
-       PROMPTZZZZ=$reset_color
-       RPROMPTZZZZ=$reset_color
-       promptzzzz=$reset_color
+       # Reset some commonly altered bits to the default
+       add-zsh-hook -D precmd "prompt_*_precmd"
+       add-zsh-hook -D preexec "prompt_*_preexec"
+       set -A zle_highlight ${zle_highlight:#default:*}
+       (( ${#zle_highlight} )) || unset zle_highlight
+
+       prompt_$1_setup "$@[2,-1]" && prompt_theme=( "$@" )
        ;;
   esac
 }
 
 prompt () {
   local prompt_opts
-  
+
   set_prompt "$@"
  
   (( $#prompt_opts )) &&
@@ -180,16 +179,18 @@ prompt_preview_theme () {
   emulate -L zsh
   local -a psv; psv=($psvar); local -a +h psvar; psvar=($psv) # Ick
   local +h PS1=$PS1 PS2=$PS2 PS3=$PS3 PS4=$PS4 RPS1=$RPS1
-  trap "${$(functions precmd):-:} ; ${$(functions preexec):-:}" 0
+  local precmd_functions preexec_functions
 
   print -n "$1 theme"
   (( $#* > 1 )) && print -n " with parameters \`$*[2,-1]'"
   print ":"
   prompt_${1}_setup "$@[2,-1]"
-  typeset +f precmd >&- && precmd
+  [[ -n ${precmd_functions[(r)prompt_${1}_precmd]} ]] &&
+    prompt_${1}_precmd
   [[ -o promptcr ]] && print -n $'\r'; :
   print -P "${PS1}command arg1 arg2 ... argn"
-  typeset +f preexec >&- && preexec
+  [[ -n ${preexec_functions[(r)prompt_${1}_preexec]} ]] &&
+    prompt_${1}_preexec
 }
 
 [[ -o kshautoload ]] || promptinit "$@"