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:
@@ -5,6 +5,7 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -519,6 +520,21 @@ func (t *Tmux) ConfigureGasTownSession(session string, theme Theme, rig, worker,
|
||||
return nil
|
||||
}
|
||||
|
||||
// LinkWindow links a window from another session into the current session.
|
||||
// This allows viewing another session's window as a tab without switching sessions.
|
||||
// Useful when already inside tmux and want to see another session.
|
||||
func (t *Tmux) LinkWindow(sourceSession string, windowIndex int) error {
|
||||
source := fmt.Sprintf("%s:%d", sourceSession, windowIndex)
|
||||
_, err := t.run("link-window", "-s", source)
|
||||
return err
|
||||
}
|
||||
|
||||
// IsInsideTmux checks if the current process is running inside a tmux session.
|
||||
// This is detected by the presence of the TMUX environment variable.
|
||||
func IsInsideTmux() bool {
|
||||
return os.Getenv("TMUX") != ""
|
||||
}
|
||||
|
||||
// SetMailClickBinding configures left-click on status-right to show mail preview.
|
||||
// This creates a popup showing the first unread message when clicking the mail icon area.
|
||||
func (t *Tmux) SetMailClickBinding(session string) error {
|
||||
|
||||
Reference in New Issue
Block a user