diff options
| author | 2026-05-14 10:58:38 +0100 | |
|---|---|---|
| committer | 2026-05-14 10:58:38 +0100 | |
| commit | 6cc182b1578fcc6e0863134185e17e29d0eed4be (patch) | |
| tree | c49560e31bf24adb39cc27e2615832d4b6c5f066 | |
| parent | 13547308fba1eacb8996ebfb9db56f2127a2e70f (diff) | |
| download | dotfiles-6cc182b1578fcc6e0863134185e17e29d0eed4be.tar.gz dotfiles-6cc182b1578fcc6e0863134185e17e29d0eed4be.tar.bz2 dotfiles-6cc182b1578fcc6e0863134185e17e29d0eed4be.zip | |
refactor(zsh): stop renaming zellij tabs from the shell
The hand-rolled `N:dir:cmd` tab labels could never stay in sync:
- After session resurrection, tab names are restored from disk but no
shell-visible event fires, so labels stayed stale until the user hit
Enter to trigger precmd.
- After closing a middle tab, zellij renumbers surviving tabs but again
emits no per-pane event, so the `N:` prefix on every tab to the right
silently became wrong.
- Once a tab has a custom name, zellij's tab-bar plugin uses it verbatim
— there's no way to keep the default `Tab #N` numbering while also
injecting dir/cmd info. The only plugin that addresses this (vmaerten/
zellij-tab-rename) requires zellij built from main.
Dropping the hooks restores zellij's built-in `Tab #N`, which is the
single label that stays correct across resurrect and renumber. The zsh
prompt already shows CWD inside the pane.
| -rw-r--r-- | dot_config/zsh/dot_zshrc | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc index 94781ac..fda6853 100644 --- a/dot_config/zsh/dot_zshrc +++ b/dot_config/zsh/dot_zshrc @@ -151,15 +151,13 @@ if [[ "$TERM" == (xterm-ghostty|st*|screen*|xterm*|rxvt*|tmux*|putty*|konsole*|g add-zsh-hook -Uz preexec xterm_title_preexec fi -# ── Zellij tab naming (dir:cmd like tmux) ──────────────────────────────────── -if [[ -n "$ZELLIJ" ]]; then - _zellij_dir() { [[ "$PWD" == "$HOME" ]] && echo '~' || echo "${PWD##*/}"; } - _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 +# ── Zellij tab naming ───────────────────────────────────────────────────────── +# Intentionally NOT renaming tabs from the shell. Zellij's built-in "Tab #N" +# is the only label that stays correct through session resurrection and +# auto-renumbering after a tab is closed; once a tab gets a custom name, the +# tab-bar plugin uses that name verbatim and there is no IPC event for shells +# to react to layout changes. The zsh prompt already shows CWD inside the +# pane, so a duplicated label in the tab bar was pure noise. # ── Recent directories ──────────────────────────────────────────────────────── autoload -Uz chpwd_recent_dirs cdr |
