fix(@scripts): 🐛 improve tmux session display with directory labels
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
4b464dfc82
commit
9a47f7f2d9
2 changed files with 45 additions and 3 deletions
37
bin/rclaude
37
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-<user>-<slug>-<epoch>". 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/tty || true)
|
||||
[ -n "$_old" ] && stty "$_old" 2>/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")
|
||||
|
|
|
|||
11
tmux.conf
11
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: <host> · <tmux session name> (read by iTerm/macOS title bar)
|
||||
# - tmux status-left: [<host>] <session>
|
||||
# - tmux status-right: <date> <time>
|
||||
set -g set-titles on
|
||||
set -g set-titles-string '#H · #S'
|
||||
set -g status-left '#[fg=cyan,bold][#H]#[default] #S '
|
||||
set -g status-right '%a %H:%M'
|
||||
set -g status-left-length 40
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue