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>_setup
in a directory in yourfpath
, such as~/myfns
in 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 longerPROMPT
andRPROMPT
.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_opts
may be assigned any ofbang
,cr
,percent
,sp
,and/or
subst
as values. The corresponding setopts (promptbang
, etc.) areturned on, all other prompt-related options are turned off. The
prompt_opts
array preserves setopts even beyond the scope of
localoptions
, should yourfunction need that.
Modify precmd and preexec
Use of
add-zsh-hook
is recommended. Theprecmd
andpreexec
hooks 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_cleanup
command 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>_preview
to display a simulatedversion of your prompt. A simple default previewer is defined by
promptinit
for themes that do not define their own. This preview function is called by
prompt -p
.Provide help
Define or autoload a function
prompt_<name>_help
to 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_setup
but since the git prompt stats are in a hookfunction the option needs to be propagated somehow.
prompt_fresh_setup
has been configurable since7653ea6f93
.