tmux

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchFindClaudeProcs

func BatchFindClaudeProcs() map[int]string

BatchFindClaudeProcs finds all claude processes and maps parent PID → args. When multiple processes share ppid=1 (orphaned/reparented), they are stored in the OrphanedProcs slice instead to avoid map key collisions.

func CapturePane

func CapturePane(p Pane) (string, error)

CapturePane captures the visible content of a tmux pane. Does NOT include scrollback.

func CurrentWindowClaudes

func CurrentWindowClaudes() []string

CurrentWindowClaudes returns project paths of Claude processes in the current tmux window.

func DetectLiveProjectPaths

func DetectLiveProjectPaths() []string

DetectLiveProjectPaths returns absolute project paths of currently running Claude processes. Used for fast phase-1 session scanning at startup.

func ExtractClaudeOAuthToken

func ExtractClaudeOAuthToken() (string, error)

ExtractClaudeOAuthToken reads the OAuth access token from the macOS Keychain.

func FindLiveProjectPaths

func FindLiveProjectPaths() map[string]bool

FindLiveProjectPaths returns project paths that have an active Claude process. Used as fallback for non-tmux environments.

func HasClaude

func HasClaude(shellPID int) bool

HasClaude checks if a pane's shell has a claude child process.

func HasClaudeSession

func HasClaudeSession(shellPID int, sessionID string) bool

HasClaudeSession checks if a pane's shell has a claude child process running the specific session ID (matches --resume <id> in args).

func InTmux

func InTmux() bool

InTmux returns true if the process is running inside a tmux session.

func KillWindow

func KillWindow(p Pane) error

KillWindow kills the tmux window containing the given pane.

func MarkLiveSessions

func MarkLiveSessions(sessions []session.Session)

MarkLiveSessions sets IsLive and IsResponding on sessions by matching running Claude processes. In tmux, matches by session ID in process args with fallback to most-recent-for-path. Outside tmux, matches by path only. Also sets TmuxWindowName on all sessions whose ProjectPath matches a tmux pane CWD.

func MoveWithAndSwitchPane

func MoveWithAndSwitchPane(target Pane) error

MoveWithAndSwitchPane moves the current pane (CSB) to the target's tmux window as a side-by-side split, then focuses the target pane.

func NewWindowClaude

func NewWindowClaude(windowName, dir, sessionID string) error

NewWindowClaude creates a new tmux window with the given name, cd's to dir, and runs "claude --resume <sessionID>".

func NewWindowClaudeNew added in v0.3.0

func NewWindowClaudeNew(windowName, dir string) error

NewWindowClaudeNew creates a new tmux window with the given name, cd's to dir, and runs "claude" (without --resume, starting a fresh session).

func OAuthTokenEnv

func OAuthTokenEnv() string

OAuthTokenEnv returns a shell snippet to export CLAUDE_CODE_OAUTH_TOKEN. Checks env first, then falls back to extracting from macOS Keychain.

func PaneCursorCol added in v0.3.0

func PaneCursorCol(p Pane) (int, error)

PaneCursorCol returns the cursor column position in the pane.

func PromptAndSend

func PromptAndSend(p Pane, promptText string) error

PromptAndSend opens a tmux command-prompt that sends the typed text to the target pane followed by Enter so Claude submits.

func SendKeys

func SendKeys(p Pane, keys string) error

SendKeys sends text input to a tmux pane followed by Enter to submit. Uses -l for the text (literal, no key-name interpretation) then a separate send-keys for Enter so it's treated as a keypress.

func SendSingleKey

func SendSingleKey(p Pane, key string) error

SendSingleKey sends a single key event to a tmux pane.

func ShellQuote

func ShellQuote(s string) string

ShellQuote wraps a string in single quotes for safe shell embedding.

func SwitchToPane

func SwitchToPane(p Pane) error

SwitchToPane switches the tmux client to the given pane.

func TeaKeyToTmux

func TeaKeyToTmux(key string) (string, bool)

TeaKeyToTmux maps a Bubble Tea key string to tmux send-keys argument(s). Returns (tmuxKey, literal). If literal is true, use send-keys -l.

Types

type ClaudeProc added in v0.3.0

type ClaudeProc struct {
	PID  int
	PPID int
	Args string
}

ClaudeProc holds information about a running claude process.

type IsolatedEnv

type IsolatedEnv struct {
	HomeDir   string // fake HOME (tmpDir)
	ConfigDir string // fake HOME/.claude
}

IsolatedEnv holds paths for an isolated Claude test environment.

func NewIsolatedEnv

func NewIsolatedEnv(prefix string) (*IsolatedEnv, error)

NewIsolatedEnv creates a temp HOME with onboarding state seeded and an empty MCP config to block all MCP servers.

func (*IsolatedEnv) Cleanup

func (e *IsolatedEnv) Cleanup()

Cleanup removes the temp directory.

func (*IsolatedEnv) MCPConfigPath

func (e *IsolatedEnv) MCPConfigPath() string

MCPConfigPath returns the path to the empty MCP config file.

func (*IsolatedEnv) RunPopup

func (e *IsolatedEnv) RunPopup(script string)

RunPopup launches the script in a tmux display-popup with a nested tmux session for scrollback support. Blocks until the popup exits.

func (*IsolatedEnv) Script

func (e *IsolatedEnv) Script(extraArgs ...string) string

Script builds a shell script that runs claude in this isolated env. Extra args are appended to the claude command.

func (*IsolatedEnv) SettingsPath

func (e *IsolatedEnv) SettingsPath() string

SettingsPath returns the path to settings.json in the config dir.

func (*IsolatedEnv) WriteSettings

func (e *IsolatedEnv) WriteSettings(data []byte) error

WriteSettings writes a JSON settings file to the config dir.

type Pane

type Pane struct {
	PaneID     string
	Command    string
	Session    string
	Window     string
	WindowName string
	Pane       string
	PID        int
	Path       string
}

Pane represents a tmux pane with its metadata.

func FindPane

func FindPane(projectPath string, sessionID ...string) (Pane, bool)

FindPane finds the tmux pane whose cwd matches projectPath and (optionally) has a claude process running in it. If sessionID is provided, prefer panes running that specific session.

func ListPanes

func ListPanes() ([]Pane, error)

ListPanes returns all tmux panes across all sessions and windows.

func SpawnHiddenWindow added in v0.3.0

func SpawnHiddenWindow(windowName, shellCmd string) (Pane, error)

SpawnHiddenWindow creates a hidden tmux window running the given command and returns the Pane reference for capture-pane. The window is created with -d (detached) so it doesn't steal focus.

Jump to

Keyboard shortcuts

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