diff options
| author | 2026-04-17 10:53:44 +0100 | |
|---|---|---|
| committer | 2026-04-17 10:53:44 +0100 | |
| commit | 011dfcf2043369abeb29759fe1b297d2e3531077 (patch) | |
| tree | 3772047962cd59429e12f4b949445f58f0ffcca8 /home | |
| parent | 372c50c16c26c16f3f2e5779baf0af3d4a4758d3 (diff) | |
| download | dotfiles-011dfcf2043369abeb29759fe1b297d2e3531077.tar.gz dotfiles-011dfcf2043369abeb29759fe1b297d2e3531077.tar.bz2 dotfiles-011dfcf2043369abeb29759fe1b297d2e3531077.zip | |
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.
Diffstat (limited to 'home')
| -rw-r--r-- | home/.config/zsh/.zshrc | 18 |
1 files 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 |
