tmux

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateConfig

func GenerateConfig(path string, scrollbackLines int) error

GenerateConfig writes a mobile-optimized tmux.conf to path.

func IsInsideTmux

func IsInsideTmux() bool

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

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps tmux CLI commands.

func NewClient

func NewClient(confPath string) *Client

NewClient creates a new Client using the given tmux config path.

func (*Client) Attach

func (c *Client) Attach(name string) error

Attach attaches to an existing tmux session, connecting stdin/stdout/stderr.

func (*Client) CapturePane added in v0.1.2

func (c *Client) CapturePane(name string) (string, error)

CapturePane returns the current visible contents of the pane in the named session. `-e` preserves escape sequences (colour) so the consumer can render ANSI; `-p` prints to stdout instead of a buffer. Follows the same CLI-shell-out style as PaneCommand / PanePID.

Visible-only: callers that need pane readiness (see pane_ready.go) must compare the current screen, not scrollback. For the live pane viewer, use CapturePaneHistory with a non-zero scrollback.

func (*Client) CapturePaneHistory added in v0.1.4

func (c *Client) CapturePaneHistory(name string, scrollback int) (string, error)

CapturePaneHistory returns the contents of the pane in the named session including up to `scrollback` lines of tmux history above the currently visible screen. `-e` preserves SGR escapes, `-p` prints to stdout, `-J` joins wrapped lines so the consumer sees logical lines instead of terminal-width fragments.

scrollback <= 0 degrades to the visible-only behaviour of CapturePane. Callers that want the entire scrollback can pass a large bound (the tmux history-limit is ~2000 by default and can be raised per session).

func (*Client) ChooseSession

func (c *Client) ChooseSession() error

ChooseSession opens the tmux session chooser, connecting stdin/stdout/stderr.

func (*Client) CurrentSession

func (c *Client) CurrentSession() (string, error)

CurrentSession returns the name of the current tmux session.

func (*Client) Detach

func (c *Client) Detach() error

Detach detaches the current tmux client.

func (*Client) Go

func (c *Client) Go(name string) error

Go navigates to the named session, switching if inside tmux or attaching otherwise.

func (*Client) HasSession

func (c *Client) HasSession(name string) bool

HasSession returns true if a tmux session with the given name exists.

func (*Client) KillServer

func (c *Client) KillServer() error

KillServer kills the tmux server. Returns nil if there is no server running.

func (*Client) KillSession

func (c *Client) KillSession(name string) error

KillSession kills the named tmux session.

func (*Client) ListSessions

func (c *Client) ListSessions() (string, error)

ListSessions returns a newline-separated list of sessions, or empty string if none.

func (*Client) NewSession

func (c *Client) NewSession(name, workdir, shellCmd string) error

NewSession creates a new detached tmux session.

func (*Client) PaneCommand

func (c *Client) PaneCommand(name string) (string, error)

PaneCommand returns the start command of the first pane in the named session.

func (*Client) PaneCurrentPath

func (c *Client) PaneCurrentPath(name string) (string, error)

PaneCurrentPath returns the current working directory of the pane in the named session.

func (*Client) PanePID

func (c *Client) PanePID(name string) (string, error)

PanePID returns the PID of the first pane in the named session.

func (*Client) RenameSession

func (c *Client) RenameSession(oldName, newName string) error

RenameSession renames a tmux session.

func (*Client) RespawnPane

func (c *Client) RespawnPane(name, shellCmd string) error

RespawnPane respawns the pane in the named session with the given shell command. The command is wrapped in /bin/sh -c so shell operators (||, &&) are interpreted. Unlike new-session, respawn-pane does not invoke $SHELL -c automatically.

func (*Client) SendEnter added in v0.1.2

func (c *Client) SendEnter(target string) error

SendEnter sends the tmux "Enter" key (without -l) to the given target. A literal `\n` via SendKeys is the LF character, which TUIs like claude interpret as "insert newline", not "submit". Sending the Enter keybind triggers the real submit path.

func (*Client) SendKeys added in v0.1.2

func (c *Client) SendKeys(target, keys string) error

SendKeys pipes keys to the given tmux target. The `-l` flag asks tmux to treat the text as a literal string (no keybinding translation), so `y\n` sends 'y' then newline, not the VI-mode key "Enter". Callers are responsible for appending a trailing `\n` when they want the remote shell / REPL to receive it as submission.

target format: "<session>:<window>.<pane>" — e.g. "alpha:0.0". Empty target is rejected to guard against a caller bug that would otherwise default to tmux's "current client" and type into the wrong place.

func (*Client) SourceConfig

func (c *Client) SourceConfig() error

SourceConfig loads the tmux config into the running server. This is needed because tmux -f only applies when starting a new server.

func (*Client) SwitchClient

func (c *Client) SwitchClient(name string) error

SwitchClient switches the tmux client to the named session.

Jump to

Keyboard shortcuts

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