crew at: don't link windows by default, add --detached flag

When running `gt crew at` from inside tmux:
- No longer auto-links the target session as a tab
- Just prints "Started X. Use C-b s to switch."
- User stays in their current pane

When running from outside tmux:
- Default: attach to the session (existing behavior)
- With -d/--detached: start session without attaching

This gives users more control over tmux session navigation and
reduces confusion for tmux newcomers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-24 15:22:12 -08:00
parent b930704b5f
commit e8dff71b37
3 changed files with 31 additions and 23 deletions

View File

@@ -12,7 +12,6 @@ import (
"github.com/steveyegge/gastown/internal/git"
"github.com/steveyegge/gastown/internal/rig"
"github.com/steveyegge/gastown/internal/style"
"github.com/steveyegge/gastown/internal/tmux"
"github.com/steveyegge/gastown/internal/workspace"
)
@@ -169,21 +168,9 @@ func isInTmuxSession(targetSession string) bool {
return currentSession == targetSession
}
// attachToTmuxSession attaches to a tmux session with smart behavior:
// - If already inside tmux: links the session as a new tab (use C-b n/p to switch)
// - If outside tmux: attaches normally (takes over terminal)
// attachToTmuxSession attaches to a tmux session.
// Should only be called from outside tmux.
func attachToTmuxSession(sessionID string) error {
// If already inside tmux, link the window as a tab instead of switching sessions
if tmux.IsInsideTmux() {
t := tmux.NewTmux()
if err := t.LinkWindow(sessionID, 0); err != nil {
return fmt.Errorf("linking window: %w", err)
}
fmt.Printf("Linked %s as a new tab. Use C-b n to switch to it.\n", sessionID)
return nil
}
// Outside tmux: attach normally
tmuxPath, err := exec.LookPath("tmux")
if err != nil {
return fmt.Errorf("tmux not found: %w", err)