简体   繁体   中英

zshell command named "prompt" in macOS?

I'm using the zshell for macOS Catalina (10.15.6). The book "Learning Shell Scripting With Zsh" describes an executable command named prompt , usable in such forms as:

$ prompt -p
$ prompt -h
$ prompt <theme_name>
$ prompt adam1 red yellow magenta

But zsh report "command not found: prompt".

How do I obtain that command, or an equivalent one.

(Everywhere I've tried to search about this just gives me links to places explaining how to set the zsh prompt, with all the usual escape sequences, "$..." symbols, etc.)

From man zshcontrib :

PROMPT THEMES
   Installation
       You  should  make  sure  all  the  functions from the Functions/Prompts
       directory of the source distribution are available; they all begin with
       the  string `prompt_' except for the special function`promptinit'.  You
       also  need  the  `colors'  and  `add-zsh-hook'  functions  from   Func-
       tions/Misc.   All these functions may already be installed on your sys-
       tem; if not, you will need to find them and copy them.   The  directory
       should  appear  as  one of the elements of the fpath array (this should
       already be the case if they were installed), and at least the  function
       promptinit  should  be autoloaded; it will autoload the rest.  Finally,
       to initialize the use of the system you need  to  call  the  promptinit
       function.   The  following  code  in your .zshrc will arrange for this;
       assume the functions are stored in the directory ~/myfns:

              fpath=(~/myfns $fpath)
              autoload -U promptinit
              promptinit

So, to get the prompt command, you can just run

$ autoload -U promptinit
$ promptinit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM