From 011dfcf2043369abeb29759fe1b297d2e3531077 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Fri, 17 Apr 2026 10:53:44 +0100 Subject: fix: create XDG state dir for chpwd recent dirs The chpwd_recent_dirs handler errors when $XDG_STATE_HOME/zsh/ doesn't exist. Add a mkdir -p guard before setting the zstyle. Also rewrites za() to properly handle zellij list-sessions output by splitting into a zsh array and filtering empty lines. Adds a $ZELLIJ nesting guard and passes explicit session name to attach. --- home/.config/zsh/.zshrc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/home/.config/zsh/.zshrc b/home/.config/zsh/.zshrc index 18aa3e6..139926d 100644 --- a/home/.config/zsh/.zshrc +++ b/home/.config/zsh/.zshrc @@ -157,6 +157,7 @@ fi # ── Recent directories ──────────────────────────────────────────────────────── autoload -Uz chpwd_recent_dirs cdr add-zsh-hook chpwd chpwd_recent_dirs +[[ -d ${XDG_STATE_HOME}/zsh ]] || mkdir -p "${XDG_STATE_HOME}/zsh" zstyle ':chpwd:*' recent-dirs-file "$XDG_STATE_HOME/zsh/chpwd-recent-dirs" zstyle ':completion:*:*:cdr:*:*' menu selection @@ -232,14 +233,17 @@ alias ng='nvim +Neogit' # Zellij: smart attach — 0 sessions: create, 1: attach, many: welcome picker za() { - local sessions=$(zellij list-sessions -ns 2>/dev/null | wc -l) - if (( sessions == 0 )); then - zellij - elif (( sessions == 1 )); then - zellij attach - else - zellij -l welcome + if [[ -n $ZELLIJ ]]; then + echo "Already inside zellij" >&2 + return 1 fi + local -a sessions=("${(@f)$(zellij list-sessions -ns 2>/dev/null)}") + sessions=(${sessions:#}) + case ${#sessions} in + 0) zellij ;; + 1) zellij attach "${sessions[1]}" ;; + *) zellij -l welcome ;; + esac } # Just -- cgit v1.2.3-70-g09d2