From 9a47f7f2d9a3021d6fece3724a2a654383eb9e0b Mon Sep 17 00:00:00 2001 From: Natalie Date: Sun, 17 May 2026 05:28:30 -0700 Subject: [PATCH] =?UTF-8?q?fix(@scripts):=20=F0=9F=90=9B=20improve=20tmux?= =?UTF-8?q?=20session=20display=20with=20directory=20labels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- bin/rclaude | 37 ++++++++++++++++++++++++++++++++++--- tmux.conf | 11 +++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/bin/rclaude b/bin/rclaude index cdaa81c..b70ab11 100755 --- a/bin/rclaude +++ b/bin/rclaude @@ -507,6 +507,29 @@ cmd_resume() { if (s=="done") return c_done return "" } + # Last two path components of cwd, e.g. "@projects/@lilith". + function last2(cwd, n, parts) { + n = split(cwd, parts, "/") + if (n == 0) return "" + if (n == 1) return parts[1] + return parts[n-1] "/" parts[n] + } + # Heuristic recovery of cwd from a tmux session name like + # "claude---". Lossy (@ became -) but + # readable for the common cases. + function tmux_dir(name) { + sub(/^claude-[^-]+-/, "", name) + sub(/-[0-9]+$/, "", name) + gsub(/--/, "/", name) + return last2(name) + } + function dir_label() { + if ($2 == "tmux") return tmux_dir($3) + if ($2 == "triage") return last2($8) + if ($2 == "session") { split($5, h, " · "); return last2(h[1]) } + return "" + } + function fit(s, n) { return length(s) > n ? substr(s, 1, n-1) "…" : s } function display() { if ($2 == "tmux") return c_tmux "▶ " r $3 @@ -517,7 +540,7 @@ cmd_resume() { return $3 } { - printf "%s%-10s%s %s", c_host, $1, r, display() + printf "%s%-10s%s %s%-22s%s %s", c_host, $1, r, c_dim, fit(dir_label(), 22), r, display() } ' if [ ! -t 0 ] || [ ! -t 2 ]; then @@ -551,11 +574,19 @@ cmd_resume() { "$_Cdim" "$_d_room" "$_d_total" "$_R" >&2 fi _last_key=$(printf %s "$_keys" | cut -c"$_count") - printf '%sselect [1-%s]:%s ' "$_Ckey" "$_last_key" "$_R" >&2 + printf '%sselect [1-%s] (q to cancel):%s ' "$_Ckey" "$_last_key" "$_R" >&2 _old=$(stty -g 2>/dev/null || true) stty -icanon -echo min 1 time 0 2>/dev/null || true _key=$(dd bs=1 count=1 2>/dev/null /dev/null || true + # Render the keystroke we just consumed. Empty (EOF), Enter, Esc, q, + # and Ctrl-C all mean "cancel" — just exit cleanly. + case $_key in + ''|q|Q|$(printf '\r')|$(printf '\n')|$(printf '\033')|$(printf '\003')) + printf '(cancelled)\n' >&2 + exit 0 + ;; + esac printf '%s\n' "$_key" >&2 _idx=0 _c=1 @@ -566,7 +597,7 @@ cmd_resume() { _c=$((_c + 1)) done if [ "$_idx" -eq 0 ]; then - echo "rclaude: invalid selection: '$_key'" >&2 + echo "rclaude: invalid selection: '$_key' (expected 1-${_last_key})" >&2 exit 1 fi _matches=$(printf '%s\n' "$_matches" | sed -n "${_idx}p") diff --git a/tmux.conf b/tmux.conf index ca41103..5382f49 100644 --- a/tmux.conf +++ b/tmux.conf @@ -29,3 +29,14 @@ set -g set-clipboard on # Keep window indexes contiguous when one closes; quiet the activity flag spam. set -g renumber-windows on setw -g monitor-activity off + +# Surface hostname everywhere — matters when stacking rclaude/ssh tmuxes across +# plum/apricot and you need to know which host the active pane is on. +# - Terminal window title: · (read by iTerm/macOS title bar) +# - tmux status-left: [] +# - tmux status-right: