about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-04-16 02:55:41 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-04-16 02:55:41 +0000
commit81002a74165dda682a1a5e7f1ff559507fd60f65 (patch)
treed88322b667f1e731ec0d5344e453ce37554abf9e /Functions
parente254c6b68aff24d5e15af114cf2921144cc73173 (diff)
downloadzsh-81002a74165dda682a1a5e7f1ff559507fd60f65.tar.gz
zsh-81002a74165dda682a1a5e7f1ff559507fd60f65.tar.xz
zsh-81002a74165dda682a1a5e7f1ff559507fd60f65.zip
Merge from trunk of workers/{21240,22672,22739}.
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Prompts/prompt_bigfade_setup5
-rw-r--r--Functions/Prompts/prompt_elite2_setup15
-rw-r--r--Functions/Prompts/prompt_elite_setup5
-rw-r--r--Functions/Prompts/prompt_fade_setup5
-rw-r--r--Functions/Prompts/prompt_fire_setup7
-rw-r--r--Functions/Prompts/prompt_zefram_setup1
-rw-r--r--Functions/Prompts/promptinit61
7 files changed, 55 insertions, 44 deletions
diff --git a/Functions/Prompts/prompt_bigfade_setup b/Functions/Prompts/prompt_bigfade_setup
index 260c0ddf0..3b73c1e0f 100644
--- a/Functions/Prompts/prompt_bigfade_setup
+++ b/Functions/Prompts/prompt_bigfade_setup
@@ -25,9 +25,8 @@ prompt_bigfade_setup () {
   local date=${3:-'white'}
   local cwd=${4:-'yellow'}
 
-  for code in 333 262 261 260 260 261 262 333 333 262 261 260 333 262 261 260 260 261 262 333 333 262 261 260; do
-    local varname=char_$code
-    : ${(P)varname=$(echo -n "\\0$code")}
+  for code in 333 262 261 260; do
+    local char_$code=$(echo -n "\\0$code")
   done
 
   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%} "
diff --git a/Functions/Prompts/prompt_elite2_setup b/Functions/Prompts/prompt_elite2_setup
index 81107748a..41080187b 100644
--- a/Functions/Prompts/prompt_elite2_setup
+++ b/Functions/Prompts/prompt_elite2_setup
@@ -20,20 +20,21 @@ prompt_elite2_setup () {
   local text_col=${1:-'cyan'}
   local parens_col=${2:-$text_col}
 
-  for code in 332 304 304 371 371 371 372 300 304 304 371 372; do
-    local varname=char_$code
-    : ${(P)varname=$(echo -n "\\0$code")}
+  for code in 332 304 300; do
+    local char_$code=$(echo -n "\\0$code")
   done
 
-  local tty=`tty|cut -d/ -f3`
   local text="%{$fg_no_bold[$text_col]%}"
   local parens="%{$fg_bold[$parens_col]%}"
-  local punctuation_color="%{$fg_bold[grey]%}"
+  local punct="%{$fg_bold[grey]%}"
   local reset="%{$reset_color%}"
 
-  PS1="$punctuation_colorÚ$textÄ$parens($text%n$punctuation_color@$text%m$parens)$textÄ$parens($text%!$punctuation_color/$text$tty$parens)$textÄ$parens($text%D{%I:%M%P}$punctuation_color:$text%D{%m/%d/%y}$parens)$textÄ$punctuation_color-$reset$prompt_newline$punctuation_colorÀ$textÄ$parens($text%#$punctuation_color:$text%~$parens)$textÄ$punctuation_color-$reset " 
+  local lpar="$parens($text"
+  local rpar="$parens)$text"
 
-  PS2="$parensÄ$textÄ$punctuation_color-$reset "
+  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 " 
+
+  PS2="$parens$char_304$text$char_304$punct-$reset "
 
   precmd () { setopt promptsubst }
   preexec () { }
diff --git a/Functions/Prompts/prompt_elite_setup b/Functions/Prompts/prompt_elite_setup
index 344da3341..53216c52a 100644
--- a/Functions/Prompts/prompt_elite_setup
+++ b/Functions/Prompts/prompt_elite_setup
@@ -20,9 +20,8 @@ prompt_elite_setup () {
   local text=${1:-'red'}
   local punctuation=${2:-'blue'}
 
-  for code in 332 304 304 371 371 371 372 300 304 304 371 372; do
-    local varname=char_$code
-    : ${(P)varname=$(echo -n "\\0$code")}
+  for code in 332 304 371 372 300; do
+    local char_$code=$(echo -n "\\0$code")
   done
 
   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%}"
diff --git a/Functions/Prompts/prompt_fade_setup b/Functions/Prompts/prompt_fade_setup
index 5b49f6105..ab908e41e 100644
--- a/Functions/Prompts/prompt_fade_setup
+++ b/Functions/Prompts/prompt_fade_setup
@@ -27,9 +27,8 @@ prompt_fade_setup () {
   local userhost=${2:-'white'}
   local date=${3:-'white'}
 
-  for code in 333 262 261 260 333 262 261 260 333 262 261 260; do
-    local varname=char_$code
-    : ${(P)varname=$(echo -n "\\0$code")}
+  for code in 333 262 261 260; do
+    local char_$code=$(echo -n "\\0$code")
   done
 
   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%} "
diff --git a/Functions/Prompts/prompt_fire_setup b/Functions/Prompts/prompt_fire_setup
index bb52fdfb7..34676d159 100644
--- a/Functions/Prompts/prompt_fire_setup
+++ b/Functions/Prompts/prompt_fire_setup
@@ -28,9 +28,8 @@ prompt_fire_setup () {
   local date=${5:-'white'}
   local cwd=${6:-'yellow'}
 
-  for code in 333 262 261 260 260 261 262 333; do
-    local varname=char_$code
-    : ${(P)varname=$(echo -n "\\0$code")}
+  for code in 333 262 261 260; do
+    local char_$code=$(echo -n "\\0$code")
   done
 
   local GRAD1="%{$char_333$char_262$char_261$char_260%}"
@@ -43,7 +42,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} '$prompt_newline$COLOR5'%~/'$GRAD0' '
   PS2=$COLOR1$GRAD1$COLOR3$GRAD2$COLOR4$GRAD1$COLOR5'>'$GRAD0' '
 
   precmd () { setopt promptsubst }
diff --git a/Functions/Prompts/prompt_zefram_setup b/Functions/Prompts/prompt_zefram_setup
index 99585edec..7b7eefb28 100644
--- a/Functions/Prompts/prompt_zefram_setup
+++ b/Functions/Prompts/prompt_zefram_setup
@@ -1,5 +1,6 @@
 function prompt_zefram_precmd {
 	local exitstatus=$?
+	setopt localoptions noxtrace noksharrays
 	psvar=(SIG)
 	[[ $exitstatus -gt 128 ]] && psvar[1]=SIG$signals[$exitstatus-127]
 	[[ $psvar[1] = SIG ]] && psvar[1]=$exitstatus
diff --git a/Functions/Prompts/promptinit b/Functions/Prompts/promptinit
index adf0d4f2d..37e437699 100644
--- a/Functions/Prompts/promptinit
+++ b/Functions/Prompts/promptinit
@@ -20,7 +20,7 @@ promptinit () {
     if [[ $theme == */prompt_(#b)(*)_setup ]]; then
       name="$match[1]"
       if [[ -r "$theme" ]]; then
-        prompt_themes=($name $prompt_themes)
+        prompt_themes=($prompt_themes $name)
         autoload -U prompt_${name}_setup
       else
         print "Couldn't read file $theme containing theme $name."
@@ -38,6 +38,29 @@ promptinit () {
   prompt_newline=$'\n%{\r%}'
 }
 
+prompt_preview_safely() {
+  print $reset_color
+  if [[ -z "$prompt_themes[(r)$1]" ]]; then
+    print "Unknown theme: $1"
+    return
+  fi
+
+  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
+
+  # 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_${1}_setup
+
+  if typeset +f prompt_${1}_preview >&/dev/null; then
+    prompt_${1}_preview "$@[2,-1]"
+  else
+    prompt_preview_theme "$@"
+  fi
+}
+
 set_prompt() {
   emulate -L zsh
   local opt preview theme usage old_theme
@@ -53,12 +76,13 @@ Options:
 
 Use prompt -h <theme> for help on specific themes.'
 
-  getopts "chlps" opt
+  getopts "chlps:" opt
   case "$opt" in
     (h|p)
       setopt localtraps
       if [[ -z "$prompt_theme[1]" ]]; then
         # 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
       else
@@ -67,7 +91,7 @@ Use prompt -h <theme> for help on specific themes.'
       ;;
   esac
   case "$opt" in
-    c) if (( $+prompt_theme )); then
+    c) if [[ -n $prompt_theme ]]; then
          print -n "Current prompt theme"
          (( $#prompt_theme > 1 )) && print -n " with parameters"
          print " is:\n  $prompt_theme"
@@ -102,33 +126,18 @@ Use prompt -h <theme> for help on specific themes.'
     p) preview=( $prompt_themes )
        (( $#* > 1 )) && preview=( "$@[2,-1]" )
        for theme in $preview; do
-         theme_args=( "$=theme" )
          [[ "$theme" == "$prompt_theme[*]" ]] && continue
-         if [[ -z "$prompt_themes[(r)$theme_args[1]]" ]]; then
-           print "\nUnknown theme: $theme_args[1]"
-           continue
-         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
-
-         if functions prompt_${theme_args[1]}_preview >&/dev/null; then
-           prompt_${theme_args[1]}_preview "${(@)theme_args[2,-1]}"
-         else
-           prompt_preview_theme "${(@)theme_args}"
-         fi
+         prompt_preview_safely "$=theme"
        done
-       print
+       print $reset_color
        ;;
     s) print "Set and save not yet implemented.  Please ensure your ~/.zshrc"
        print "contains something similar to the following:\n"
        print "  autoload -U promptinit"
        print "  promptinit"
        print "  prompt $*[2,-1]"
-       ;;
+       shift
+       ;&
     *) if [[ "$1" == 'random' ]]; then
          local random_themes
          if (( $#* == 1 )); then
@@ -167,14 +176,18 @@ prompt () {
 }
 
 prompt_preview_theme () {
+  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
+
   print -n "$1 theme"
   (( $#* > 1 )) && print -n " with parameters \`$*[2,-1]'"
   print ":"
   prompt_${1}_setup "$@[2,-1]"
   precmd
-  print -n -P "${PS1}"
+  [[ -o promptcr ]] && print -n $'\r'; :
+  print -P "${PS1}command arg1 arg2 ... argn"
   preexec
-  print "command arg1 arg2 ... argn"
 }
 
 [[ -o kshautoload ]] || promptinit "$@"