Jelajahi Sumber

Add nix shell indicator in prompt

Thomas Dy 5 tahun lalu
induk
melakukan
aaa651c692
2 mengubah file dengan 9 tambahan dan 2 penghapusan
  1. 8 2
      .zsh/prompt.zsh
  2. 1 0
      .zshrc

+ 8 - 2
.zsh/prompt.zsh

@@ -8,10 +8,11 @@ local user='%F{yellow}%B%n%b%f'
 local host='%F{blue}%B%M%b%f'
 local dir='%F{yellow}%~%f'
 local git='$(git_prompt_string)'
-local error='%F{red}%B%(?..%?)%b%f'
+local nix='$(nix_shell_prompt_string)'
+local error='%F{red}%B%?%b%f'
 
 PROMPT="$time $user@$host $dir $git%# "
-RPROMPT="$error"
+RPROMPT="%(?.$nix.$error)"
 
 # Show Git branch/tag, or name-rev if on detached head
 parse_git_branch() {
@@ -75,3 +76,8 @@ git_prompt_string() {
   fi
 }
 
+nix_shell_prompt_string() {
+  if [ -n "$IN_NIX_SHELL" ]; then
+    echo "[%F{yellow}nix%f]"
+  fi
+}

+ 1 - 0
.zshrc

@@ -6,6 +6,7 @@ zplug rimraf/k
 zplug tarrasch/zsh-bd
 zplug zsh-users/zsh-syntax-highlighting
 zplug zsh-users/zaw
+zplug chisui/zsh-nix-shell
 zplug "${HOME}/.zsh", from:local
 if [ -f "$HOME/.zshrc.local" ]; then
   zplug "$HOME/.zshrc.local", from:local