mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-05 11:01:13 +02:00
manual/8337
This commit is contained in:
parent
6e17cbf670
commit
95230a1684
1 changed files with 65 additions and 70 deletions
|
@ -34,15 +34,11 @@ promptinit () {
|
||||||
prompt_newline=$(echo -ne "\n%{\r%}")
|
prompt_newline=$(echo -ne "\n%{\r%}")
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt () {
|
set_prompt() {
|
||||||
local -A prompt_opts
|
emulate -L zsh
|
||||||
local opt
|
local opt preview theme usage old_theme
|
||||||
|
|
||||||
set_prompt() {
|
usage='Usage: prompt <options>
|
||||||
emulate -L zsh
|
|
||||||
local opt preview theme usage old_theme
|
|
||||||
|
|
||||||
usage='Usage: prompt <options>
|
|
||||||
Options:
|
Options:
|
||||||
-l List currently available prompt themes
|
-l List currently available prompt themes
|
||||||
-p [<themes>] Preview given themes (defaults to all)
|
-p [<themes>] Preview given themes (defaults to all)
|
||||||
|
@ -50,69 +46,68 @@ Options:
|
||||||
-s <theme> Set and save theme
|
-s <theme> Set and save theme
|
||||||
<theme> Switch to new theme immediately (changes not saved)'
|
<theme> Switch to new theme immediately (changes not saved)'
|
||||||
|
|
||||||
getopts "hlps" opt
|
getopts "hlps" opt
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
h)
|
h) if [[ -n "$2" && -n $prompt_themes[(r)$2] ]]; then
|
||||||
if [[ -n "$2" && -n $prompt_themes[(r)$2] ]]; then
|
if functions prompt_$2_help >/dev/null; then
|
||||||
if functions prompt_$2_help >/dev/null; then
|
print "Help for $2 theme:\n"
|
||||||
print "Help for $2 theme:\n"
|
prompt_$2_help
|
||||||
prompt_$2_help
|
else
|
||||||
else
|
print "No help available for $2 theme"
|
||||||
print "No help available for $2 theme"
|
fi
|
||||||
fi
|
else
|
||||||
else
|
print "$usage"
|
||||||
print "$usage"
|
fi
|
||||||
fi
|
;;
|
||||||
;;
|
l) print Currently available prompt themes:
|
||||||
l)
|
print $prompt_themes
|
||||||
print Currently available prompt themes:
|
return
|
||||||
print $prompt_themes
|
;;
|
||||||
return
|
p) if (( ! $+prompt_theme )); then
|
||||||
;;
|
print "Cannot preview; current prompt is non-themeable and would"
|
||||||
p)
|
print "be destroyed."
|
||||||
if (( ! $+prompt_theme )); then
|
return
|
||||||
print "Cannot preview; current prompt is non-themeable and would"
|
fi
|
||||||
print "be destroyed."
|
preview=( $prompt_themes )
|
||||||
return
|
[[ -n "$2" && -n $prompt_themes[(r)$2] ]] && preview=( $*[2,-1] )
|
||||||
fi
|
for theme in $preview; do
|
||||||
preview=( $prompt_themes )
|
[[ $theme == $prompt_theme[1] ]] && continue
|
||||||
[[ -n "$2" && -n $prompt_themes[(r)$2] ]] && preview=( $*[2,-1] )
|
print "\nTheme: $theme"
|
||||||
for theme in $preview; do
|
prompt_${theme}_setup
|
||||||
[[ $theme == $prompt_theme[1] ]] && continue
|
precmd
|
||||||
print "\nTheme: $theme"
|
print -n -P "${PS1}"
|
||||||
prompt_${theme}_setup
|
preexec
|
||||||
precmd
|
print "command arg1 arg2 ... argn"
|
||||||
print -n -P "${PS1}"
|
done
|
||||||
preexec
|
print
|
||||||
print "command arg1 arg2 ... argn"
|
prompt_${prompt_theme}_setup
|
||||||
done
|
;;
|
||||||
print
|
s) print "Set and save not yet implemented. Please ensure your ~/.zshrc"
|
||||||
prompt_${prompt_theme}_setup
|
print "contains something similar to the following:\n"
|
||||||
;;
|
print " autoload -U promptinit"
|
||||||
s)
|
print " promptinit"
|
||||||
print "Set and save not yet implemented. Please ensure your ~/.zshrc"
|
print " prompt $*[2,-1]"
|
||||||
print "contains something similar to the following:\n"
|
;;
|
||||||
print " autoload -U promptinit"
|
*) if [[ -z "$1" || -z $prompt_themes[(r)$1] ]]; then
|
||||||
print " promptinit"
|
print "$usage"
|
||||||
print " prompt $*[2,-1]"
|
return
|
||||||
;;
|
fi
|
||||||
*)
|
prompt_$1_setup $*[2,-1]
|
||||||
if [[ -z "$1" || -z $prompt_themes[(r)$1] ]]; then
|
prompt_theme=( $* )
|
||||||
print "$usage"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
prompt_$1_setup $*[2,-1]
|
|
||||||
prompt_theme=( $* )
|
|
||||||
|
|
||||||
# Avoid screwing up the environment listing
|
# Avoid screwing up the environment listing
|
||||||
PSZZZZ=$reset_color
|
PSZZZZ=$reset_color
|
||||||
RPSZZZZ=$reset_color
|
RPSZZZZ=$reset_color
|
||||||
PROMPTZZZZ=$reset_color
|
PROMPTZZZZ=$reset_color
|
||||||
RPROMPTZZZZ=$reset_color
|
RPROMPTZZZZ=$reset_color
|
||||||
promptzzzz=$reset_color
|
promptzzzz=$reset_color
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prompt () {
|
||||||
|
local -A prompt_opts
|
||||||
|
local opt
|
||||||
|
|
||||||
set_prompt "$@"
|
set_prompt "$@"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue