Commit 8ea396f3c301

Vincent Demeester <vincent@sbr.pm>
2019-07-06 21:46:13
profiles.zsh: add nix-shell prompt
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 6e1871b
Changed files (1)
modules
profiles
assets
modules/profiles/assets/zsh/prompt.zsh
@@ -17,6 +17,16 @@ function git_stash() {
   git stash list 2> /dev/null | wc -l | sed -e "s/ *\([0-9]*\)/\+\1 /g" | sed -e "s/+0 //"
 }
 
+function prompt_nix-shell() {
+  if [[ -n "$IN_NIX_SHELL" ]]; then
+    if [[ "$IN_NIX_SHELL" == "pure" ]]; then
+      echo "๐ŸŒ  "
+    else
+      echo "๐Ÿš "
+    fi
+  fi
+}
+
 function prompt_pwd() {
   if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then
     local homerepo=${$(git rev-parse --show-toplevel)/#${HOME}/\~}
@@ -86,7 +96,8 @@ local git='%{${fg_bold[yellow]}%}$(git_prompt_info)%{${reset_color}%}'
 local git_stashes='$(git_stash)'
 local bg_job='%{${fg_bold[black]}%}$(prompt_bg_job)%{${reset_color}%}'
 local aws='%{${fg_bold[black]}%}$(aws_vault)%{${reset_color}%}'
+local nix_shell='$(prompt_nix-shell)'
 
-PROMPT="$cwd$usr$bg_job$git_author$git$git_stashes$aws$colored_char"
+PROMPT="$cwd$usr$bg_job$git_author$git$git_stashes$aws$nix_shell$colored_char"
 PROMPT2=$colored_char
 RPROMPT2='[%_]'