Add prompt theme options #2
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Make prompt theme configurable, it should support:
Writing Themes
The first step for adding your own theme is to choose a name for it, and
create a file
prompt_<name>_setupin a directory in yourfpath, such as~/myfnsin the example above. The file should at minimum contain assignmentsfor the prompt variables that your theme wishes to modify. By convention,
themes use
PS1,PS2,RPS1, etc., rather than the longerPROMPTandRPROMPT.The file is autoloaded as a function in the current shell context, so it may
contain any necessary commands to customize your theme, including defining
additional functions. To make some complex tasks easier, your setup function may
also do any of the following:
Assign prompt_opts
The array
prompt_optsmay be assigned any ofbang,cr,percent,sp,and/or
substas values. The corresponding setopts (promptbang, etc.) areturned on, all other prompt-related options are turned off. The
prompt_optsarray preserves setopts even beyond the scope of
localoptions, should yourfunction need that.
Modify precmd and preexec
Use of
add-zsh-hookis recommended. Theprecmdandpreexechooks areautomatically adjusted if the prompt theme changes or is disabled.
Declare cleanup
If your function makes any other changes that should be undone when the theme is
disabled, your setup function may call
prompt_cleanupcommand where commandshould be suitably quoted. If your theme is ever disabled or replaced by
another, command is executed with
eval. You may declare more than one suchcleanup hook.
Define preview
Define or autoload a function
prompt_<name>_previewto display a simulatedversion of your prompt. A simple default previewer is defined by
promptinitfor themes that do not define their own. This preview function is called by
prompt -p.Provide help
Define or autoload a function
prompt_<name>_helpto display documentation orhelp text for your theme. This help function is called by
prompt -h.Options for almostontop and RPS1 are easy enough as they are controlled
directory from
prompt_fresh_setupbut since the git prompt stats are in a hookfunction the option needs to be propagated somehow.
prompt_fresh_setuphas been configurable since7653ea6f93.