summaryrefslogtreecommitdiffstats
path: root/Functions/Prompts/promptinit
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-10-20 16:03:55 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-10-20 16:03:55 +0000
commit95230a1684a7d864a5db128b8fc56669c6555ded (patch)
tree13341d58276d943846fb7f0fc21dd7c6c11becbb /Functions/Prompts/promptinit
parentzsh-workers/8335 (diff)
downloadzsh-95230a1684a7d864a5db128b8fc56669c6555ded.tar
zsh-95230a1684a7d864a5db128b8fc56669c6555ded.tar.gz
zsh-95230a1684a7d864a5db128b8fc56669c6555ded.tar.bz2
zsh-95230a1684a7d864a5db128b8fc56669c6555ded.tar.lz
zsh-95230a1684a7d864a5db128b8fc56669c6555ded.tar.xz
zsh-95230a1684a7d864a5db128b8fc56669c6555ded.tar.zst
zsh-95230a1684a7d864a5db128b8fc56669c6555ded.zip
manual/8337
Diffstat (limited to 'Functions/Prompts/promptinit')
-rw-r--r--Functions/Prompts/promptinit135
1 files changed, 65 insertions, 70 deletions
diff --git a/Functions/Prompts/promptinit b/Functions/Prompts/promptinit
index 157cb1e38..285b9e4d9 100644
--- a/Functions/Prompts/promptinit
+++ b/Functions/Prompts/promptinit
@@ -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 "$@"