From: Adam Spiers <adam@thelonious.new.ox.ac.uk>
To: zsh workers mailing list <zsh-workers@sunsite.auc.dk>
Subject: Re: PATCH: prompt theme system improvements
Date: Fri, 19 Nov 1999 01:51:43 +0000 [thread overview]
Message-ID: <19991119015143.A29956@thelonious.new.ox.ac.uk> (raw)
In-Reply-To: <991118175142.ZM9631@candle.brasslantern.com>
Bart Schaefer (schaefer@candle.brasslantern.com) wrote:
> On Nov 18, 2:53pm, Adam Spiers wrote:
> } Subject: PATCH: prompt theme system improvements
> }
> } OK, finally here's a patch to the prompt system which vastly improves
> } it.
>
> I was just fooling with this, and after running
>
> prompt -p
>
> I get the message
>
> set_prompt: command not found: prompt__setup [71]
Doh. The
p) if (( ! $+prompt_theme )); then
print "Cannot preview; current prompt is non-themeable and would"
print "be destroyed."
return
fi
bit should have caught this, but I'd already declared prompt_theme so
the test went wrong.
However, it's pretty bad that you can't preview any themes until
you're using one, so this patch changes that, and restores PS[1-4],
RPS1 and pre{cmd,exec} to their original values after the preview if
$prompt_theme wasn't set.
It also fixes some other bugs I found.
N.B. I forgot to mention that that last patch added the following files:
Functions/Prompts/prompt_bigfade_setup
Functions/Prompts/prompt_fade_setup
Functions/Prompts/prompt_zefram_setup
Tanaka, can you please add them to the CVS repository? Sorry! The
following patch also fixes the relevant .distfiles.
Index: Functions/Prompts/.distfiles
===================================================================
RCS file: /projects/zsh/zsh/Functions/Prompts/.distfiles,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 .distfiles
--- Functions/Prompts/.distfiles 1999/11/03 09:06:29 1.1.1.2
+++ Functions/Prompts/.distfiles 1999/11/19 01:46:15
@@ -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
'
Index: Functions/Prompts/prompt_adam2_setup
===================================================================
RCS file: /projects/zsh/zsh/Functions/Prompts/prompt_adam2_setup,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 prompt_adam2_setup
--- Functions/Prompts/prompt_adam2_setup 1999/11/18 15:15:27 1.1.1.3
+++ Functions/Prompts/prompt_adam2_setup 1999/11/19 01:46:16
@@ -46,20 +46,17 @@
# 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_paren="%{$fg_bold[grey]%}("
+ prompt_r_paren="%{$fg_bold[grey]%})"
- prompt_l_bracket=$'%{$fg_bold[grey]%}['
- prompt_r_bracket=$'%{$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]%}"
Index: Functions/Prompts/prompt_fire_setup
===================================================================
RCS file: /projects/zsh/zsh/Functions/Prompts/prompt_fire_setup,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 prompt_fire_setup
--- Functions/Prompts/prompt_fire_setup 1999/11/18 15:15:27 1.1.1.3
+++ Functions/Prompts/prompt_fire_setup 1999/11/19 01:46:16
@@ -43,7 +43,7 @@
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 }
Index: Functions/Prompts/promptinit
===================================================================
RCS file: /projects/zsh/zsh/Functions/Prompts/promptinit,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 promptinit
--- Functions/Prompts/promptinit 1999/11/18 15:15:27 1.1.1.8
+++ Functions/Prompts/promptinit 1999/11/19 01:46:28
@@ -81,10 +81,11 @@
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 @@
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 @@
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 @@
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
next prev parent reply other threads:[~1999-11-19 9:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-11-18 14:53 Adam Spiers
1999-11-18 15:43 ` Adam Spiers
1999-11-18 17:51 ` Bart Schaefer
1999-11-19 1:51 ` Adam Spiers [this message]
1999-11-19 10:29 ` Tanaka Akira
1999-11-19 11:42 ` Oliver Kiddle
1999-11-19 10:34 Sven Wischnowsky
1999-11-19 10:55 ` Tanaka Akira
1999-11-19 11:01 Sven Wischnowsky
1999-11-19 12:01 Sven Wischnowsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19991119015143.A29956@thelonious.new.ox.ac.uk \
--to=adam@thelonious.new.ox.ac.uk \
--cc=adam@spiers.net \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).