From f045790589e476537316e44225ce70b69e51a45c Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Fri, 17 Apr 2026 10:53:41 +0100 Subject: fix: make za smart-attach (create/attach/pick based on session count) 0 sessions: create new. 1 session: attach directly. Multiple: open the welcome picker. Replaces broken 'zellij attach -c' which required a session name argument. --- home/.config/zsh/.zshrc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/home/.config/zsh/.zshrc b/home/.config/zsh/.zshrc index a05bbc8..f22e5f2 100644 --- a/home/.config/zsh/.zshrc +++ b/home/.config/zsh/.zshrc @@ -219,8 +219,17 @@ alias nview='nvim -R' alias nv='nvim -R' alias ng='nvim +Neogit' -# Zellij: attach to session or create if it doesn't exist (name is optional) -alias za='zellij attach -c' +# 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 + fi +} # Just alias j='just' -- cgit v1.2.3-70-g09d2