1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-23 00:41:03 +01:00

manual/8337

This commit is contained in:
Tanaka Akira 1999-10-20 16:03:55 +00:00
parent 6e17cbf670
commit 95230a1684

View file

@ -34,15 +34,11 @@ promptinit () {
prompt_newline=$(echo -ne "\n%{\r%}")
}
prompt () {
local -A prompt_opts
local opt
set_prompt() {
emulate -L zsh
local opt preview theme usage old_theme
set_prompt() {
emulate -L zsh
local opt preview theme usage old_theme
usage='Usage: prompt <options>
usage='Usage: prompt <options>
Options:
-l List currently available prompt themes
-p [<themes>] Preview given themes (defaults to all)
@ -50,69 +46,68 @@ Options:
-s <theme> Set and save theme
<theme> Switch to new theme immediately (changes not saved)'
getopts "hlps" opt
case "$opt" in
h)
if [[ -n "$2" && -n $prompt_themes[(r)$2] ]]; then
if functions prompt_$2_help >/dev/null; then
print "Help for $2 theme:\n"
prompt_$2_help
else
print "No help available for $2 theme"
fi
else
print "$usage"
fi
;;
l)
print Currently available prompt themes:
print $prompt_themes
return
;;
p)
if (( ! $+prompt_theme )); then
print "Cannot preview; current prompt is non-themeable and would"
print "be destroyed."
return
fi
preview=( $prompt_themes )
[[ -n "$2" && -n $prompt_themes[(r)$2] ]] && preview=( $*[2,-1] )
for theme in $preview; do
[[ $theme == $prompt_theme[1] ]] && continue
print "\nTheme: $theme"
prompt_${theme}_setup
precmd
print -n -P "${PS1}"
preexec
print "command arg1 arg2 ... argn"
done
print
prompt_${prompt_theme}_setup
;;
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]"
;;
*)
if [[ -z "$1" || -z $prompt_themes[(r)$1] ]]; then
print "$usage"
return
fi
prompt_$1_setup $*[2,-1]
prompt_theme=( $* )
getopts "hlps" opt
case "$opt" in
h) if [[ -n "$2" && -n $prompt_themes[(r)$2] ]]; then
if functions prompt_$2_help >/dev/null; then
print "Help for $2 theme:\n"
prompt_$2_help
else
print "No help available for $2 theme"
fi
else
print "$usage"
fi
;;
l) print Currently available prompt themes:
print $prompt_themes
return
;;
p) if (( ! $+prompt_theme )); then
print "Cannot preview; current prompt is non-themeable and would"
print "be destroyed."
return
fi
preview=( $prompt_themes )
[[ -n "$2" && -n $prompt_themes[(r)$2] ]] && preview=( $*[2,-1] )
for theme in $preview; do
[[ $theme == $prompt_theme[1] ]] && continue
print "\nTheme: $theme"
prompt_${theme}_setup
precmd
print -n -P "${PS1}"
preexec
print "command arg1 arg2 ... argn"
done
print
prompt_${prompt_theme}_setup
;;
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]"
;;
*) if [[ -z "$1" || -z $prompt_themes[(r)$1] ]]; then
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
;;
esac
}
# Avoid screwing up the environment listing
PSZZZZ=$reset_color
RPSZZZZ=$reset_color
PROMPTZZZZ=$reset_color
RPROMPTZZZZ=$reset_color
promptzzzz=$reset_color
;;
esac
}
prompt () {
local -A prompt_opts
local opt
set_prompt "$@"