aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-19 15:16:09 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-19 15:16:09 +0100
commit40563230031c0992b48ce3a32d2a2516a370c47a (patch)
treea23f605c2da094f243b57cb4c3f086b07515504a /dot_config
parente5dd5aa8d3e11559eeefef413adbd23f2c8a2d8c (diff)
downloaddotfiles-40563230031c0992b48ce3a32d2a2516a370c47a.tar.gz
dotfiles-40563230031c0992b48ce3a32d2a2516a370c47a.tar.bz2
dotfiles-40563230031c0992b48ce3a32d2a2516a370c47a.zip
refactor(zsh): rename zellij tabs to dir:cmd without position prefix
Zellij's default 'Tab #N' name is fixed at tab creation (the N is the immutable creation index, not the live position) and never auto-updates when tabs are closed or moved, so the default is actively misleading after any tab reorg. Tmux's `renumber-windows on` has no zellij equivalent and no plugin solves this cleanly. Restore shell-side renaming but drop the position prefix `N:` — visual order in the tab bar implies position. After a session resurrect or closing a middle tab, untouched tabs still show their previous dir:cmd label until the next prompt fires there, but at least there is no misleading number to second-guess.
Diffstat (limited to 'dot_config')
-rw-r--r--dot_config/yazi/yazi.toml4
-rw-r--r--dot_config/zsh/dot_zshrc22
2 files changed, 18 insertions, 8 deletions
diff --git a/dot_config/yazi/yazi.toml b/dot_config/yazi/yazi.toml
index 0387edc..6c53cfe 100644
--- a/dot_config/yazi/yazi.toml
+++ b/dot_config/yazi/yazi.toml
@@ -8,7 +8,9 @@ title_format = "Yazi: {cwd}"
# (otherwise yazi treats the viewer as an unfinished task and prompts on quit).
[opener]
open = [{ run = 'xdg-open "$@"', desc = "Open", orphan = true }]
-view-md = [{ run = 'glow -p -- "$@"', desc = "Render markdown (glow)", block = true }]
+view-md = [
+ { run = 'glow -p -- "$@"', desc = "Render markdown (glow)", block = true },
+]
# Render markdown with glow inside yazi instead of letting xdg-open hand it
# to a text editor.
diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc
index f5c3337..27daa2c 100644
--- a/dot_config/zsh/dot_zshrc
+++ b/dot_config/zsh/dot_zshrc
@@ -158,13 +158,21 @@ if [[ "$TERM" == (xterm-ghostty|st*|screen*|xterm*|rxvt*|tmux*|putty*|konsole*|g
add-zsh-hook -Uz preexec xterm_title_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.
+# ── Zellij tab naming (dir:cmd, no position prefix) ──────────────────────────
+# Zellij's default "Tab #N" name is baked in at tab creation (the N is the
+# immutable creation index, not the live position) and never updates when
+# tabs are closed or moved — so the default is actively misleading. We rename
+# to `dir:cmd` from the shell hooks; position is implied by visual order in
+# the tab bar. Untouched tabs after a resurrect or after closing a middle tab
+# will still show their previous dir:cmd until the next prompt fires there,
+# but at least there's no wrong *number* attached.
+if [[ -n "$ZELLIJ" ]]; then
+ _zellij_dir() { [[ "$PWD" == "$HOME" ]] && echo '~' || echo "${PWD##*/}"; }
+ _zellij_tab_precmd() { zellij action rename-tab "$(_zellij_dir)" 2>/dev/null; }
+ _zellij_tab_preexec() { zellij action rename-tab "$(_zellij_dir):${1%% *}" 2>/dev/null; }
+ add-zsh-hook precmd _zellij_tab_precmd
+ add-zsh-hook preexec _zellij_tab_preexec
+fi
# ── Recent directories ────────────────────────────────────────────────────────
autoload -Uz chpwd_recent_dirs cdr