Configure tmux and keep the iTerm2 tab titles working inside it - #122
Open
mattmenefee wants to merge 1 commit into
Open
Configure tmux and keep the iTerm2 tab titles working inside it#122mattmenefee wants to merge 1 commit into
mattmenefee wants to merge 1 commit into
Conversation
tmux has been installed and aliased here without ever being configured, and without being recorded in the Brewfile, so a fresh machine got the alias but not the binary behind it. That alias was broken in its own right: `ta` falls back to `tn`, which no plugin or file ever defined — not the oh-my-zsh tmux plugin, which is not in the plugin list and does not define it either — so `ta` exited with "command not found: tn" whenever there was no session to attach to. Most of the new configuration is conventional: mouse support, a large scrollback, 1-indexed windows that renumber on close, vi copy keys, splits that inherit the pane's directory, vim's home row for moving between panes, and a status line drawn on `bg=default` so it inherits the terminal background rather than fighting whichever iTerm2 profile is loaded. Three settings were chosen against tmux's measured defaults rather than its remembered ones. `escape-time` and `mode-keys` already hold the wanted values here — the first because tmux lowered that default from 500ms only recently, the second because tmux reads vi from an $EDITOR of `mvim -v` — and both are pinned so that neither an older tmux nor a changed $EDITOR moves them. `set-clipboard` goes to `on` rather than the default `external`, which adds only the inbound half, an application in a pane populating a tmux buffer over OSC 52; the outbound half that carries a yank back through SSH is already on by default. `aggressive-resize` is the one that changes behavior materially: windows size to the smallest client actually viewing them instead of the smallest client attached at all, so a second, smaller client stops shrinking the first one's panes. Adding the config alone would have quietly broken the tab titles, which is why home/.zsh/iterm2-tab-title.zsh changes here too. It emitted OSC 1, and tmux discards OSC 1 while acting on OSC 2 — checked by sending each to a live server and reading pane_title back rather than by reading the manual. Inside a pane the title now goes out as OSC 2, tmux keeps it as the pane title, and `set-titles-string "#T"` republishes it to iTerm2 unchanged, so a tab still shows the branch when idle and the running command otherwise, branch first. Outside tmux the bytes are unchanged, OSC 1 still being the sequence that names a tab without also retitling the window. The SetUserVar sequence that publishes the directory fails inside tmux for a different reason — tmux forwards only what it is told to — so it is now wrapped in tmux's DCS passthrough, which `allow-passthrough on` in the config enables. Both halves are needed: with either one missing the titles freeze at whatever was set before tmux started, and nothing says why. `tm` joins the newly defined `tn` for attach-or-create against a fixed session name, the form worth having when the reason to reach for tmux is a connection that may drop. home/.tmux.conf is a new top-level file rather than a member of an already-symlinked directory, so it needs a `homesick link` run before it takes effect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
home/.tmux.conf, the first tmux configuration in this repo, and recordstmuxin theBrewfile— it was installed on this machine but never tracked, so a fresh machine got thetaalias without the binary behind it.ta, which has never worked when no session was running: it falls back totn, and nothing definedtn— not this repo, and not the oh-my-zshtmuxplugin (which is not in the plugin list and definestksv/tl/tmuxconf/tdsinstead). Addstn, plustmfor attach-or-create against a fixed session name.home/.zsh/iterm2-tab-title.zshtmux-aware. Without this, adding a tmux config would have silently killed the tab titles: that file emits OSC 1, and tmux discards OSC 1 while acting on OSC 2. Titles now go out as OSC 2 inside a pane, andset-titles-string "#T"republishes them to iTerm2 unchanged. TheSetUserVarsequence carrying the directory is wrapped in tmux's DCS passthrough for the same reason, which is whatallow-passthrough onin the config enables.On the config's contents
Most of it is conventional — mouse support, a large scrollback, 1-indexed windows that renumber on close, vi copy keys, splits that inherit the pane's directory, vim's home row for pane movement, and a status line on
bg=defaultso it inherits the terminal background instead of fighting the active iTerm2 profile.The settings were picked against tmux 3.7's measured defaults rather than the ones most guides still quote:
escape-time 10Esc.mode-keys vi$EDITOR="mvim -v". Pinned so copy mode doesn't change keys if$EDITORdoes.set-clipboard onexternal.onadds the inbound half, letting an application in a pane populate a tmux buffer over OSC 52.aggressive-resize onNote on activation
home/.tmux.confis a new top-level file rather than a member of an already-symlinked directory, so it needs ahomesick linkrun (or a single symlink) before it takes effect.Test plan
tmux -f home/.tmux.conf new-session -dloads with no config errors on tmux 3.7c~/.tmux.confsymlink resolves, and a default-path tmux server reads backallow-passthrough=on,aggressive-resize=on,set-titles-string=#T— none of which are defaults_tab_title_idlesetspane_titleto the git branch (main), and_tab_title_running rspecsets it to▶ rspec_tab_title_emitemits the original OSC 1 byte-for-byte (^[]1;BRANCH^G)zsh -n, the same gate CI runsta,tn, andtmall resolve in a fresh zsh▶ cmdwhile a command runs, anduser.dirkeeps updating through the DCS passthroughbrew bundlereconciles the newtmuxentry