Add a quick named-session binding and fix theme reload in tmux

prefix S now prompts for a name and runs new-session directly, replacing
the `<prefix> :` then `new -s name` command-mode round trip.

Session numbering in choose-tree (prefix s) turned out to be
session_id, an internal per-server counter with no base-index
equivalent, so it can't be made to start at 1 the way windows do;
named sessions plus C-s search in the tree are the workaround.

Also fixed a bug found while testing: `<prefix> r` re-sources the
whole config, and the trailing `source-file ~/.tmux-dark.conf` at the
end always ran, clobbering a light-themed session on every manual
reload. It now checks the invoking client's theme like the
client-attached hook already does.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013t7aQbc4EyYtab1crvSFTd
This commit is contained in:
Jonny Barnes 2026-08-14 09:36:27 +01:00
commit f8d525b7eb
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8

10
tmux
View file

@ -14,6 +14,10 @@ set -g renumber-windows on
# don't detach when closing a window if other windows remain
set -g detach-on-destroy off
# prompt for a name and create a session in one step, instead of
# `<prefix> :` then `new -s name`
bind-key S command-prompt -p "New session name:" "new-session -s '%%'"
# reload config file (change file location to your the tmux.conf you want to use)
unbind r
bind r source-file ~/.tmux.conf
@ -51,5 +55,7 @@ set-hook -g client-dark-theme 'source-file ~/.tmux-dark.conf'
# client attaches. Sourcing is idempotent, so the overlap is harmless.
set-hook -g client-attached 'if -F "#{==:#{client_theme},light}" "source-file ~/.tmux-light.conf" "source-file ~/.tmux-dark.conf"'
# Default before any client has attached and reported a theme.
source-file ~/.tmux-dark.conf
# Default before any client has attached and reported a theme. This also
# runs on manual reload (`r` below), so check the invoking client's theme
# rather than always falling back to dark and clobbering a light session.
if -F "#{==:#{client_theme},light}" "source-file ~/.tmux-light.conf" "source-file ~/.tmux-dark.conf"