From 95230a1684a7d864a5db128b8fc56669c6555ded Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Wed, 20 Oct 1999 16:03:55 +0000 Subject: manual/8337 --- Functions/Prompts/promptinit | 135 +++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 70 deletions(-) (limited to 'Functions') 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 + usage='Usage: prompt Options: -l List currently available prompt themes -p [] Preview given themes (defaults to all) @@ -50,69 +46,68 @@ Options: -s Set and save 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 "$@" -- cgit 1.4.1