From c7486b4694edd2315d8a76dd4bbbe97e13888e4e Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Thu, 8 Oct 2026 11:29:26 -0400 Subject: [PATCH] feat(ghostty): add tmux session launcher script --- dot_local/bin/executable_ghostty-tmux | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 dot_local/bin/executable_ghostty-tmux diff --git a/dot_local/bin/executable_ghostty-tmux b/dot_local/bin/executable_ghostty-tmux new file mode 100755 index 0000000..4d5e6f3 --- /dev/null +++ b/dot_local/bin/executable_ghostty-tmux @@ -0,0 +1,23 @@ +#!/bin/bash +# Ghostty's `command`: every Ghostty window gets its own tmux session, never +# a mirror of another window's. Reclaim the oldest detached session (left by +# a closed window, or restored by tmux-continuum after a reboot) so closed +# windows don't pile up sessions; otherwise start a new one. The first window +# after boot starts the server, which is what triggers continuum's restore. +# ponytail: two windows opened in the same instant can claim the same detached +# session; take a lock (flock) here if that ever bites. +# +# The session's @tab-bg is set to Ghostty's own background (its theme, not +# Omarchy's), so the tab arrows tmux paints in that color match the window. + +oldest=$(tmux list-sessions -f '#{==:#{session_attached},0}' \ + -F '#{session_created} #{session_name}' 2>/dev/null | sort -n | head -1 | cut -d' ' -f2-) + +bg=$(ghostty +show-config 2>/dev/null | sed -n 's/^background = //p') +set_bg=() +[[ -n $bg ]] && set_bg=(\; set-option @tab-bg "$bg") + +if [[ -n $oldest ]]; then + exec tmux attach-session -t "=$oldest" "${set_bg[@]}" +fi +exec tmux new-session "${set_bg[@]}"