aboutsummaryrefslogtreecommitdiff
path: root/config/p10k-rainbow.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-10-27 12:30:39 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-10-27 12:30:39 +0300
commitd40f54f30de765b764d916f0128e524940b3ad9c (patch)
tree6e52b208f50972fbfd5bd0c604e9cf0cd51db53f /config/p10k-rainbow.zsh
parente7520409d117e454d9a688c8e403d5fedf55993c (diff)
define instant_prompt_example to demonstrate how to add segments to instant prompt
Diffstat (limited to 'config/p10k-rainbow.zsh')
-rw-r--r--config/p10k-rainbow.zsh28
1 files changed, 24 insertions, 4 deletions
diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh
index 713ba18d..751a85e3 100644
--- a/config/p10k-rainbow.zsh
+++ b/config/p10k-rainbow.zsh
@@ -828,16 +828,36 @@
# Example of a user-defined prompt segment. Function prompt_example will be called on every
# prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or
- # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user.
+ # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and yellow text on red background
+ # greeting the user.
#
# Type `p10k help segment` for documentation and a more sophisticated example.
function prompt_example() {
- p10k segment -b red -f yellow -i '⭐' -t 'hello, %n'
+ p10k segment -b 1 -f 3 -i '⭐' -t 'hello, %n'
+ }
+
+ # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job
+ # is to generate the prompt segment for display in instant prompt. See
+ # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt.
+ #
+ # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function
+ # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k
+ # will replay these calls without actually calling instant_prompt_*. It is imperative that
+ # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this
+ # rule is not observed, the content of instant prompt will be incorrect.
+ #
+ # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If
+ # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt.
+ function instant_prompt_example() {
+ # Since prompt_example always makes the same `p10k segment` calls, we can call it from
+ # instant_prompt_example. This will give us the same `example` prompt segment in the instant
+ # and regular prompts.
+ prompt_example
}
# User-defined prompt segments can be customized the same way as built-in segments.
- # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=4
- typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}'
+ # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=3
+ # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐'
# Instant prompt mode.
#