tmux

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ProgramAider = "aider"
View Source
const ProgramClaude = "claude"
View Source
const ProgramGemini = "gemini"
View Source
const TmuxPrefix = "hivemind_"

Variables

This section is empty.

Functions

func CleanupSessions

func CleanupSessions(cmdExec cmd.Executor) error

CleanupSessions kills all tmux sessions that start with "session-"

Types

type Pty

type Pty struct{}

Pty starts a "real" pseudo-terminal (PTY) using the creack/pty package.

func (Pty) Close

func (pt Pty) Close()

func (Pty) Start

func (pt Pty) Start(cmd *exec.Cmd) (*os.File, error)

type PtyFactory

type PtyFactory interface {
	Start(cmd *exec.Cmd) (*os.File, error)
	Close()
}

func MakePtyFactory

func MakePtyFactory() PtyFactory

type TmuxSession

type TmuxSession struct {

	// AppendArgs holds additional arguments appended to the program's argument list
	// during Start(). Each element is a separate arg — no shell splitting is done.
	// Set this before calling Start().
	AppendArgs []string
	// ProgressFunc is called with (stage, description) during Start() to report progress.
	ProgressFunc func(stage int, desc string)
	// contains filtered or unexported fields
}

TmuxSession represents a managed tmux session

func NewTmuxSession

func NewTmuxSession(name string, program string, skipPermissions bool) *TmuxSession

NewTmuxSession creates a new TmuxSession with the given name and program.

func NewTmuxSessionWithDeps

func NewTmuxSessionWithDeps(name string, program string, skipPermissions bool, ptyFactory PtyFactory, cmdExec cmd.Executor) *TmuxSession

NewTmuxSessionWithDeps creates a new TmuxSession with provided dependencies for testing.

func (*TmuxSession) Attach

func (t *TmuxSession) Attach() (chan struct{}, error)

func (*TmuxSession) CapturePaneContent

func (t *TmuxSession) CapturePaneContent() (string, error)

CapturePaneContent captures the content of the tmux pane

func (*TmuxSession) CapturePaneContentWithOptions

func (t *TmuxSession) CapturePaneContentWithOptions(start, end string) (string, error)

CapturePaneContentWithOptions captures the pane content with additional options start and end specify the starting and ending line numbers (use "-" for the start/end of history)

func (*TmuxSession) Close

func (t *TmuxSession) Close() error

Close terminates the tmux session and cleans up resources

func (*TmuxSession) Detach

func (t *TmuxSession) Detach()

Detach disconnects from the current tmux session. It panics if detaching fails. At the moment, there's no way to recover from a failed detach.

func (*TmuxSession) DetachSafely

func (t *TmuxSession) DetachSafely() error

DetachSafely disconnects from the current tmux session without panicking

func (*TmuxSession) DoesSessionExist

func (t *TmuxSession) DoesSessionExist() bool

func (*TmuxSession) GetPTY

func (t *TmuxSession) GetPTY() *os.File

GetPTY returns the master PTY file descriptor for direct I/O.

func (*TmuxSession) GetPanePID

func (t *TmuxSession) GetPanePID() (int, error)

func (*TmuxSession) GetSanitizedName

func (t *TmuxSession) GetSanitizedName() string

GetSanitizedName returns the tmux session name used for tmux commands.

func (*TmuxSession) HasUpdated

func (t *TmuxSession) HasUpdated() (updated bool, hasPrompt bool)

HasUpdated checks if the tmux pane content has changed since the last tick. It also returns true if the tmux pane has a prompt for aider or claude code.

func (*TmuxSession) IsPaneDead added in v0.2.2

func (t *TmuxSession) IsPaneDead() bool

IsPaneDead returns true if the tmux pane has exited (the program finished) but the session is still alive due to remain-on-exit.

func (*TmuxSession) ListWindows added in v0.2.1

func (t *TmuxSession) ListWindows() ([]WindowInfo, error)

ListWindows returns all windows in this tmux session. Claude Code's tmux spawn backend creates sub-agents as additional windows (index > 0) in the same session, so window count minus one equals sub-agent count.

func (*TmuxSession) RespawnPane added in v0.2.2

func (t *TmuxSession) RespawnPane(workDir string) error

RespawnPane restarts a dead pane with the user's default shell in the given working directory. This allows the user to manually restart the agent (e.g. claude -r) after it exits.

func (*TmuxSession) Restore

func (t *TmuxSession) Restore() error

Restore attaches to an existing session and restores the window size

func (*TmuxSession) SendKeys

func (t *TmuxSession) SendKeys(keys string) error

func (*TmuxSession) SendTextViaTmux added in v0.2.2

func (t *TmuxSession) SendTextViaTmux(text string) error

SendTextViaTmux sends literal text to the tmux session using `tmux send-keys -l`, then presses Enter. This goes through tmux's server directly rather than through the client PTY, making it more reliable for delivering prompts to programs.

func (*TmuxSession) SetDetachedSize

func (t *TmuxSession) SetDetachedSize(width, height int) error

SetDetachedSize set the width and height of the session while detached. This makes the tmux output conform to the specified shape.

func (*TmuxSession) Start

func (t *TmuxSession) Start(workDir string) error

Start creates and starts a new tmux session, then attaches to it. Program is the command to run in the session (ex. claude). workdir is the git worktree directory.

func (*TmuxSession) TapDAndEnter

func (t *TmuxSession) TapDAndEnter() error

TapDAndEnter sends 'D' followed by an enter keystroke to the tmux pane.

func (*TmuxSession) TapEnter

func (t *TmuxSession) TapEnter() error

TapEnter sends an enter keystroke to the tmux pane.

type WindowInfo added in v0.2.1

type WindowInfo struct {
	Index   int
	Name    string
	PanePID int
}

WindowInfo holds metadata about a single tmux window.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL