Smart attach: link window when inside tmux

When 'gt X attach' is run from inside a tmux session, link the target
session's window as a new tab instead of switching sessions entirely.
Use C-b n/p to navigate between tabs.

Outside tmux: unchanged behavior (full attach)
Inside tmux: links window as tab for convenient multi-session viewing

- Add tmux.LinkWindow() and tmux.IsInsideTmux()
- Update attachToTmuxSession() with smart detection
- Update mayor, deacon, crew, refinery attach commands
This commit is contained in:
Steve Yegge
2025-12-22 15:42:31 -08:00
parent fcda775db3
commit e9587bf045
4 changed files with 35 additions and 30 deletions

View File

@@ -3,7 +3,6 @@ package cmd
import (
"errors"
"fmt"
"os/exec"
"strings"
"time"
@@ -199,13 +198,8 @@ func runDeaconAttach(cmd *cobra.Command, args []string) error {
}
// Session uses a respawn loop, so Claude restarts automatically if it exits
// Use exec to replace current process with tmux attach
tmuxPath, err := exec.LookPath("tmux")
if err != nil {
return fmt.Errorf("tmux not found: %w", err)
}
return execCommand(tmuxPath, "attach-session", "-t", DeaconSessionName)
// Use shared attach helper (smart: links if inside tmux, attaches if outside)
return attachToTmuxSession(DeaconSessionName)
}
func runDeaconStatus(cmd *cobra.Command, args []string) error {