From 7b4e3b4b0174fda96ce7e7dec446effe76e95700 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Sat, 15 Jun 2024 13:12:39 +0200 Subject: [PATCH] pinwheel: Add `zsh` prompts when in `nix shell` and/or `direnv` --- hosts/pinwheel/modules/zsh/default.nix | 14 ++++++++++++++ hosts/pinwheel/modules/zsh/p10k-config/p10k.zsh | 2 ++ 2 files changed, 16 insertions(+) diff --git a/hosts/pinwheel/modules/zsh/default.nix b/hosts/pinwheel/modules/zsh/default.nix index 2370918..31106db 100644 --- a/hosts/pinwheel/modules/zsh/default.nix +++ b/hosts/pinwheel/modules/zsh/default.nix @@ -54,6 +54,20 @@ in "bindkey -v '^?' backward-delete-char" "bindkey '^a' beginning-of-line" "bindkey '^e' end-of-line" + '' + function prompt_in_nix_shell() { + if [[ -n "$IN_NIX_SHELL" ]]; then + p10k segment -f yellow -t "nix"; + fi + } + '' + '' + function prompt_in_direnv() { + if [[ -n "$DIRENV_DIR" ]]; then + p10k segment -f yellow -t "direnv" + fi + } + '' ]; }; }; diff --git a/hosts/pinwheel/modules/zsh/p10k-config/p10k.zsh b/hosts/pinwheel/modules/zsh/p10k-config/p10k.zsh index ec1e075..dfd53cf 100644 --- a/hosts/pinwheel/modules/zsh/p10k-config/p10k.zsh +++ b/hosts/pinwheel/modules/zsh/p10k-config/p10k.zsh @@ -54,6 +54,8 @@ command_execution_time # previous command duration virtualenv # python virtual environment prompt_char # prompt symbol + in_nix_shell + in_direnv ) # Right prompt segments.