commit 58a84ba9c971fc3fe11e2c08dca44188ed04ca34
parent cea82d3ec36cab383fd8ea77befaabdffda9f96b
Author: Vincent Demeester <vincent@sbr.pm>
Date: Tue, 28 Apr 2020 02:06:51 +0200
Add nix-shell information to the prompt
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat:
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/modules/profiles/assets/zsh/prompt.zsh b/modules/profiles/assets/zsh/prompt.zsh
@@ -57,15 +57,16 @@
#rvm # ruby version from rvm (https://rvm.io)
kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io)
- aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
+ #aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
# aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/)
# azure # azure account name (https://docs.microsoft.com/en-us/cli/azure)
context # user@hostname
- nordvpn # nordvpn connection status, linux only (https://nordvpn.com/)
+ #nordvpn # nordvpn connection status, linux only (https://nordvpn.com/)
#ranger # ranger shell (https://github.com/ranger/ranger)
# vpn_ip # virtual private network indicator
# ram # free RAM
# load # CPU load
+ in_nix_shell
time # current time
# =========================[ Line #2 ]=========================
#newline
@@ -829,15 +830,15 @@
# Custom prefix.
# typeset -g POWERLEVEL9K_TIME_PREFIX='%fat '
- # 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.
- #
- # Type `p10k help segment` for documentation and a more sophisticated example.
- function prompt_example() {
- p10k segment -f 208 -i '⭐' -t 'hello, %n'
+ function prompt_in_nix_shell() {
+ if test -n "${IN_NIX_SHELL}"; then
+ if test -n "${NIX_SHELL_PACKAGES}"; then
+ p10k segment -f yellow -i '🛡' -t "{ ${NIX_SHELL_PACKAGES} }"
+ else
+ p10k segment -f yellow -t "🛡"
+ fi
+ fi
}
-
# 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.
@@ -847,14 +848,9 @@
# 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
+
+ function instant_prompt_in_nix_shell() {
+ prompt_in_nix_shell
}
# User-defined prompt segments can be customized the same way as built-in segments.