aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLibravatar sommerfeld <[email protected]>2026-04-17 10:53:48 +0100
committerLibravatar sommerfeld <[email protected]>2026-04-17 10:53:48 +0100
commit482c3c5a474d401b352a7d78035b2df5d525f31c (patch)
tree061e4e9ec9fb9256991ec55fd0cdb98da2953377
parentb4e68789513c657c4c584e08c7051756c796126b (diff)
downloaddotfiles-482c3c5a474d401b352a7d78035b2df5d525f31c.tar.gz
dotfiles-482c3c5a474d401b352a7d78035b2df5d525f31c.tar.bz2
dotfiles-482c3c5a474d401b352a7d78035b2df5d525f31c.zip
fix: query zellij tab index dynamically on each prompt
The tab index was captured once at shell startup and cached in a variable. When tabs were closed and renumbered, the stale index persisted, showing wrong numbers. Now _zellij_tab_idx is a function that queries current-tab-info on every precmd/preexec call.
-rw-r--r--home/.config/zsh/.zshrc7
1 files changed, 3 insertions, 4 deletions
diff --git a/home/.config/zsh/.zshrc b/home/.config/zsh/.zshrc
index 139926d..22f70d6 100644
--- a/home/.config/zsh/.zshrc
+++ b/home/.config/zsh/.zshrc
@@ -146,10 +146,9 @@ fi
# ── Zellij tab naming (dir:cmd like tmux) ────────────────────────────────────
if [[ -n "$ZELLIJ" ]]; then
_zellij_dir() { [[ "$PWD" == "$HOME" ]] && echo '~' || echo "${PWD##*/}"; }
- _zellij_tab_idx=$(zellij action current-tab-info 2>/dev/null | grep -oP 'position: \K\d+')
- (( _zellij_tab_idx++ )) # 0-indexed → 1-indexed
- _zellij_tab_precmd() { zellij action rename-tab "$_zellij_tab_idx:$(_zellij_dir)" 2>/dev/null; }
- _zellij_tab_preexec() { zellij action rename-tab "$_zellij_tab_idx:$(_zellij_dir):${1%% *}" 2>/dev/null; }
+ _zellij_tab_idx() { echo $(( $(zellij action current-tab-info 2>/dev/null | grep -oP 'position: \K\d+') + 1 )); }
+ _zellij_tab_precmd() { zellij action rename-tab "$(_zellij_tab_idx):$(_zellij_dir)" 2>/dev/null; }
+ _zellij_tab_preexec() { zellij action rename-tab "$(_zellij_tab_idx):$(_zellij_dir):${1%% *}" 2>/dev/null; }
add-zsh-hook precmd _zellij_tab_precmd
add-zsh-hook preexec _zellij_tab_preexec
fi