2021-05-04 01:59:31 +00:00
|
|
|
# Prompt
|
2012-04-14 10:48:55 +00:00
|
|
|
|
|
|
|
Loads prompt [themes][1].
|
|
|
|
|
2021-05-04 01:59:31 +00:00
|
|
|
## Settings
|
2012-04-14 10:48:55 +00:00
|
|
|
|
2017-07-21 01:07:29 +00:00
|
|
|
### Prompt Theme
|
|
|
|
|
2021-05-05 17:59:01 +00:00
|
|
|
To select a prompt theme, add the following to _`${ZDOTDIR:-$HOME}/.zpreztorc`_,
|
|
|
|
and replace `'<name>'` with the name of the theme you wish to load. Setting it
|
|
|
|
to `'random'` will load a random theme every time.
|
2012-04-14 10:48:55 +00:00
|
|
|
|
2017-07-21 01:07:29 +00:00
|
|
|
```sh
|
2021-05-05 17:59:01 +00:00
|
|
|
zstyle ':prezto:module:prompt' theme '<name>'
|
2017-07-21 01:07:29 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Prompt Display Length
|
|
|
|
|
|
|
|
To change working directory prompt display length from 'short', set the
|
2021-05-04 01:59:31 +00:00
|
|
|
following to 'long' (without `~` expansion) or 'full' (with `~` expansion) in
|
2021-05-05 17:59:01 +00:00
|
|
|
_`${ZDOTDIR:-$HOME}/.zpreztorc`_.
|
2017-07-21 01:07:29 +00:00
|
|
|
|
|
|
|
```sh
|
|
|
|
zstyle ':prezto:module:prompt' pwd-length 'short'
|
|
|
|
```
|
2012-04-14 10:48:55 +00:00
|
|
|
|
2017-09-06 18:18:09 +00:00
|
|
|
### Display Return Value
|
|
|
|
|
|
|
|
Some prompts display the return value in the prompt. If a prompt has support,
|
|
|
|
this can be disabled with the following snippet.
|
|
|
|
|
|
|
|
```sh
|
|
|
|
zstyle ':prezto:module:prompt' show-return-val 'no'
|
|
|
|
```
|
|
|
|
|
2021-05-04 01:59:31 +00:00
|
|
|
## Theming
|
2012-09-10 01:48:56 +00:00
|
|
|
|
|
|
|
A prompt theme is an autoloadable function file with a special name,
|
|
|
|
`prompt_name_setup`, placed anywhere in `$fpath`, but for the purpose of this
|
2021-05-05 17:59:01 +00:00
|
|
|
project, themes **should** be placed in the _modules/prompt/functions_
|
2012-09-10 01:48:56 +00:00
|
|
|
directory.
|
|
|
|
|
2019-07-25 22:14:43 +00:00
|
|
|
### Required Variables
|
|
|
|
|
|
|
|
To ensure that your function works with the editor-info module you'll need to
|
2021-05-05 17:59:01 +00:00
|
|
|
set the following variable in _`${ZDOTDIR:-$HOME}/.zpreztorc`_:
|
2019-07-25 22:14:43 +00:00
|
|
|
|
2021-05-04 01:59:31 +00:00
|
|
|
```sh
|
|
|
|
# Tell prezto we can manage this prompt
|
|
|
|
zstyle ':prezto:module:prompt' managed 'yes'
|
2019-07-25 22:14:43 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
This is to ensure compatibility with outside prompts, while allowing prezto
|
|
|
|
and prezto-compatible prompts to take full advantage of the editor module.
|
|
|
|
This should be set in the `prompt_name_setup` function after you've added
|
|
|
|
any additional hooks with `add-zsh-hook precmd prompt_name_precmd`. See below
|
|
|
|
for additional information about functions and hooks.
|
|
|
|
|
2012-09-10 01:48:56 +00:00
|
|
|
### Theme Functions
|
|
|
|
|
|
|
|
There are three theme functions, a setup function, a help function, and
|
|
|
|
a preview function. The setup function **must** always be defined. The help
|
|
|
|
function and the preview functions are optional.
|
|
|
|
|
2017-07-21 01:07:29 +00:00
|
|
|
#### `prompt_name_setup`
|
2012-09-10 01:48:56 +00:00
|
|
|
|
|
|
|
This function is called by the `prompt` function to install the theme. This
|
|
|
|
function may define other functions as necessary to maintain the prompt,
|
|
|
|
including a function that displays help or a function used to preview it.
|
|
|
|
|
|
|
|
**Do not call this function directly.**
|
|
|
|
|
2013-03-09 04:35:22 +00:00
|
|
|
The most basic example of this function can be seen below.
|
2012-09-10 01:48:56 +00:00
|
|
|
|
2017-07-21 01:07:29 +00:00
|
|
|
```sh
|
|
|
|
function prompt_name_setup {
|
|
|
|
PROMPT='%m%# '
|
|
|
|
RPROMPT=''
|
|
|
|
}
|
|
|
|
```
|
2012-09-10 01:48:56 +00:00
|
|
|
|
2017-07-21 01:07:29 +00:00
|
|
|
#### `prompt_name_help`
|
2012-09-10 01:48:56 +00:00
|
|
|
|
|
|
|
If the `prompt_name_setup` function is customizable via parameters, a help
|
|
|
|
function **should** be defined. The user will access it via `prompt -h name`.
|
|
|
|
|
2014-11-14 20:12:21 +00:00
|
|
|
The most basic example of this function can be seen below.
|
2012-09-10 01:48:56 +00:00
|
|
|
|
2017-07-21 01:07:29 +00:00
|
|
|
```sh
|
|
|
|
function prompt_name_help {
|
|
|
|
cat <<EOH
|
|
|
|
This prompt is color-scheme-able. You can invoke it thus:
|
2012-09-10 01:48:56 +00:00
|
|
|
|
2017-07-21 01:07:29 +00:00
|
|
|
prompt theme [<color1>] [<color2>]
|
2012-09-10 01:48:56 +00:00
|
|
|
|
2017-07-21 01:07:29 +00:00
|
|
|
where the color is for the left-hand prompt.
|
|
|
|
EOH
|
|
|
|
}
|
|
|
|
```
|
2012-09-10 01:48:56 +00:00
|
|
|
|
2017-07-21 01:07:29 +00:00
|
|
|
#### `prompt_name_preview`
|
2012-09-10 01:48:56 +00:00
|
|
|
|
|
|
|
If the `prompt_name_setup` function is customizable via parameters, a preview
|
|
|
|
function **should** be defined. The user will access it via `prompt -p name`.
|
|
|
|
|
2014-11-14 20:12:21 +00:00
|
|
|
The most basic example of this function can be seen below.
|
2012-09-10 01:48:56 +00:00
|
|
|
|
2017-07-21 01:07:29 +00:00
|
|
|
```sh
|
|
|
|
function prompt_name_preview {
|
|
|
|
if (( $# > 0 )); then
|
|
|
|
prompt_preview_theme theme "$@"
|
|
|
|
else
|
|
|
|
prompt_preview_theme theme red green blue
|
|
|
|
print
|
|
|
|
prompt_preview_theme theme yellow magenta black
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
```
|
2012-09-10 01:48:56 +00:00
|
|
|
|
|
|
|
### Hook Functions
|
|
|
|
|
2021-05-05 17:59:01 +00:00
|
|
|
There are many Zsh [hook][2] functions, but mostly the _precmd_ hook will be
|
2012-09-10 01:48:56 +00:00
|
|
|
used.
|
|
|
|
|
2017-07-21 01:07:29 +00:00
|
|
|
#### `prompt_name_precmd`
|
2012-09-10 01:48:56 +00:00
|
|
|
|
|
|
|
This hook is called before the prompt is displayed and is useful for getting
|
|
|
|
information to display in a prompt.
|
|
|
|
|
|
|
|
When calling functions to get information to display in a prompt, do not assume
|
|
|
|
that all the dependencies have been loaded. Always check for the availability of
|
|
|
|
a function before you calling it.
|
|
|
|
|
2021-05-04 01:59:31 +00:00
|
|
|
**Do not register hook functions. They will be automatically registered by the
|
|
|
|
`prompt` function.**
|
2012-09-10 01:48:56 +00:00
|
|
|
|
2014-11-14 20:12:21 +00:00
|
|
|
The most basic example of this function can be seen below.
|
2012-09-10 01:48:56 +00:00
|
|
|
|
2017-07-21 01:07:29 +00:00
|
|
|
```sh
|
|
|
|
function prompt_name_precmd {
|
|
|
|
if (( $+functions[git-info] )); then
|
|
|
|
git-info
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
```
|
2012-09-10 01:48:56 +00:00
|
|
|
|
2021-05-04 01:59:31 +00:00
|
|
|
## Troubleshooting
|
2017-10-24 19:52:32 +00:00
|
|
|
|
2021-05-04 01:59:31 +00:00
|
|
|
### Fonts aren't displaying properly
|
2017-10-24 19:52:32 +00:00
|
|
|
|
|
|
|
On most systems, themes which use special characters need to have a patched font
|
|
|
|
installed and configured properly.
|
|
|
|
|
|
|
|
Powerline provides some information on [terminal support][4] and [how to install
|
|
|
|
patched fonts][5] which should fix most font issues.
|
|
|
|
|
2021-05-04 01:59:31 +00:00
|
|
|
## Authors
|
2012-04-14 10:48:55 +00:00
|
|
|
|
2021-05-05 17:59:01 +00:00
|
|
|
_The authors of this module should be contacted via the [issue tracker][3]._
|
2012-04-14 10:48:55 +00:00
|
|
|
|
2021-05-04 01:59:31 +00:00
|
|
|
- [Sorin Ionescu](https://github.com/sorin-ionescu)
|
2012-04-14 10:48:55 +00:00
|
|
|
|
2021-05-04 01:59:31 +00:00
|
|
|
[1]: https://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Prompt-Themes
|
|
|
|
[2]: https://zsh.sourceforge.net/Doc/Release/Functions.html#Hook-Functions
|
2012-09-10 01:48:56 +00:00
|
|
|
[3]: https://github.com/sorin-ionescu/prezto/issues
|
2021-05-04 01:59:31 +00:00
|
|
|
[4]: https://powerline.readthedocs.io/en/master/usage.html#terminal-emulator-requirements
|
|
|
|
[5]: https://powerline.readthedocs.io/en/latest/installation.html#fonts-installation
|