all repos — nixfiles @ 0b5545aec273e35baee25ee91949a0247e873801

System and user configuration, managed by nix and home-manager

zsh: replace agkozak prompt with powerlevel10k
Alan Pearce alan@alanpearce.eu
Mon, 22 May 2023 19:09:47 +0200
commit

0b5545aec273e35baee25ee91949a0247e873801

parent

4a4ab6d89a833895e26effa213fbc0e64b5e16ac

2 files changed, 13 insertions(+), 36 deletions(-)

jump to
M user/settings/zsh.nixuser/settings/zsh.nix
@@ -69,10 +69,6 @@ }; 
     plugins = map mkZshPlugin [
       {
-        name = "agkozak-zsh-prompt";
-        src = pkgs.agkozak-zsh-prompt.src;
-      }
-      {
         name = "zsh-bd";
         file = "bd.plugin.zsh";
         src = pkgs.zsh-bd.src;
@@ -90,6 +86,11 @@ rev = "598675303044df8e9d04722f3adff4f63a238922";           # date = 2017-07-19T21:59:49+09:00;
           sha256 = "08bjm1dd2mpv8rk8x6yvm6gj490rgimmiq7ln4jr5hik2k3mm82r";
         };
+      }
+      {
+        name = "zsh-powerlevel10k";
+        src = pkgs.zsh-powerlevel10k.src;
+        file = "powerlevel10k.zsh-theme";
       }
     ];
 
@@ -203,6 +204,12 @@ path=($HOME/.local/bin $path)       fi
     '';
 
+    initExtraFirst = ''
+      if [[ -r "${config.xdg.cacheHome}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then
+        source "${config.xdg.cacheHome}/p10k-instant-prompt-''${(%):-%n}.zsh"
+      fi
+      typeset -g POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true
+    '';
     initExtra =
       ''
         typeset -T GHQ_ROOT ghq_root
M user/zsh/zshrcuser/zsh/zshrc
@@ -135,39 +135,9 @@ PROMPT='%B%F{green}%n %F{blue}%~%b%f %# '
   unsetopt zle
 else
-  AGKOZAK_USER_HOST_DISPLAY=${+SSH_CLIENT}
-  AGKOZAK_SHOW_STASH=0
-  AGKOZAK_SHOW_VIRTUALENV=0
-  AGKOZAK_PROMPT_DIRTRIM=0
-
-  check_kubectl_context () {
-    if [[ "$PWD" =~ satoshipay ]]
-    then
-      kubectl_context=$(kubectl config current-context)
-      kubectl_namespace=$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"${kubectl_context}\")].context.namespace}")
-      if [[ $kubectl_context =~ production ]]
-      then
-        kubectl_colour=red
-        kubectl_release=satoshipay-${kubectl_namespace}
-      else
-        kubectl_colour=yellow
-        if [[ -z $mr ]]
-        then
-          kubectl_release=satoshipay-${kubectl_namespace}-staging
-        else
-          kubectl_release=story-${mr}-${kubectl_namespace}
-        fi
-      fi
-      prompt_context="%F{$kubectl_colour}[${kubectl_context}:${kubectl_namespace}]%f"
-    else
-      prompt_context=
-    fi
-  }
-  if [[ -z $SSH_CLIENT ]]
+  if [[ -f "$ZDOTDIR/.p10k.zsh" ]]
   then
-    precmd_functions+=(check_kubectl_context)
-    AGKOZAK_LEFT_PROMPT_ONLY=${+SSH_CLIENT}
-    AGKOZAK_CUSTOM_RPROMPT='${prompt_context}%(3V.%F{${AGKOZAK_COLORS_BRANCH_STATUS}%3v%f.)'
+    source $ZDOTDIR/.p10k.zsh
   fi
 fi