Browse Source

Add custom prompt support

Thomas Dy 5 years ago
parent
commit
9bf0358d69
2 changed files with 22 additions and 1 deletions
  1. 17 0
      .zsh/_custom.zsh
  2. 5 1
      .zsh/prompt.zsh

+ 17 - 0
.zsh/_custom.zsh

@@ -0,0 +1,17 @@
+function custsh_script() {
+  echo $HOME/.zsh/custom/$1.zsh
+}
+
+CUSTOM_SHELL_SCRIPT=$(custsh_script $CUSTOM_SHELL)
+if [ -f "$CUSTOM_SHELL_SCRIPT" ] && [ ! -x "$CUSTOM_SHELL_SCRIPT" ]; then
+  source $CUSTOM_SHELL_SCRIPT
+fi
+
+function custsh() {
+  CUSTOM_SHELL_SCRIPT=$(custsh_script $1)
+  if [ -x "$CUSTOM_SHELL_SCRIPT" ]; then
+    source $CUSTOM_SHELL_SCRIPT
+  else
+    CUSTOM_SHELL=$1 zsh
+  fi
+}

+ 5 - 1
.zsh/prompt.zsh

@@ -85,7 +85,11 @@ git_prompt_string() {
 }
 
 nix_shell_prompt_string() {
-  echo "[%F{yellow}nix%f]"
+  if [ -n "$NIX_SHELL_NAME" ]; then
+    echo "[%F{yellow}nix%f:%F{green}$NIX_SHELL_NAME%f]"
+  else
+    echo "[%F{yellow}nix%f]"
+  fi
 }
 
 k8s_prompt_string() {