tmux

package module
v0.0.0-...-6d46591 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 9 Imported by: 0

README

tmux

Go Reference

A comprehensive Go library for programmatically interacting with tmux sessions, windows, and panes. This library provides a clean, type-safe interface to manage tmux through Go, making it easy to automate terminal multiplexing tasks and build tmux-based applications.

Features

  • Complete tmux Integration: Full access to tmux sessions, windows, and panes
  • Type-Safe API: Strongly typed structures for all tmux entities
  • Context Support: All operations accept context.Context for cancellation and timeouts
  • Comprehensive Data Access: Retrieve all tmux fields and properties
  • Session Management: Create, rename, delete, and manage sessions
  • Window Operations: Handle windows, layouts, and navigation
  • Pane Control: Split, resize, and manage panes programmatically
  • Server Information: Query tmux server status and client connections
  • Error Handling: Robust error handling throughout the API

Requirements

  • tmux installed on your system

Installation

go get github.com/owenthereal/tmux

Quick Start

package main

import (
    "context"
    "log"

    "github.com/owenthereal/tmux"
)

func main() {
    ctx := context.Background()

    // Initialize tmux client
    t, err := tmux.Default()
    if err != nil {
        log.Fatal(err)
    }

    // Create a new session
    session, err := t.New(ctx)
    if err != nil {
        log.Fatal(err)
    }

    // Attach to the session
    err = session.Attach(ctx)
    if err != nil {
        log.Fatal(err)
    }
}

API Overview

Session Management

Create and manage tmux sessions with full control over their properties:

ctx := context.Background()

// Create a new session with custom options
session, err := t.NewSession(ctx, &tmux.SessionOptions{
    StartDirectory: "/home/user",
    Name:           "my-session",
})

// List all sessions
sessions, err := t.ListSessions(ctx)

// Attach to a session
err = session.Attach(ctx)

// Rename a session
err = session.Rename(ctx, "new-name")
Window Operations

Manage windows within sessions:

// Create a new window
window, err := session.New(ctx)

// Get window by index
window, err := session.GetWindowByIndex(ctx, 0)

// Select a specific layout
err = window.SelectLayout(ctx, tmux.WindowLayoutEvenVertical)

// Move window to another session
err = window.Move(ctx, targetSession, 0)
Pane Management

Control individual panes within windows:

// Get first pane
pane, err := window.FirstPane(ctx)

// Split pane (returns the new pane)
newPane, err := pane.Split(ctx)

// Split with options (horizontal/vertical)
newPane, err = pane.SplitWindow(ctx, &tmux.SplitWindowOptions{
    SplitDirection: tmux.PaneSplitDirectionHorizontal,
})

// Execute command in pane
err = pane.SendKeys(ctx, "ls -la")

// Execute command and press Enter
err = pane.SendLine(ctx, "ls -la")
Server and Client Information

Query tmux server status and connected clients:

// Get server information
server, err := t.GetServerInformation(ctx)
fmt.Printf("tmux version: %s\n", server.Version)

// List connected clients
clients, err := t.ListClients(ctx)
for _, client := range clients {
    fmt.Printf("Client: %s, Session: %s\n", client.Tty, client.Session)
}

Data Structures

This library provides comprehensive data structures that capture all tmux fields. For example, the Session struct includes:

type Session struct {
    Activity          string   // Last activity time
    Alerts            string   // Alert flags
    Attached          int      // Number of attached clients
    AttachedList      []string // List of attached clients
    Created           string   // Creation time
    Format            bool     // Format flag
    Group             string   // Session group
    GroupAttached     int      // Number of attached clients in group
    GroupAttachedList []string // List of attached clients in group
    GroupList         []string // List of sessions in group
    GroupManyAttached bool     // Multiple clients attached to group
    GroupSize         int      // Number of sessions in group
    Grouped           bool     // Whether session is grouped
    Id                string   // Session ID
    LastAttached      string   // Last attachment time
    ManyAttached      bool     // Multiple clients attached
    Marked            bool     // Marked flag
    Name              string   // Session name
    Path              string   // Working directory
    Stack             string   // Stack information
    Windows           int      // Number of windows
}

Examples

The project includes comprehensive examples in the examples/ directory:

  • create/: Basic session, window, and pane creation
  • sessions/: Session management operations
  • windows_panes/: Window and pane manipulation
  • listing/: Querying and listing tmux entities
  • get_server_info/: Server information retrieval
  • list_clients/: Client connection management
Example: Advanced Session Management
func main() {
    ctx := context.Background()

    t, err := tmux.Default()
    if err != nil {
        log.Fatal(err)
    }

    // Create session with specific options
    session, err := t.NewSession(ctx, &tmux.SessionOptions{
        StartDirectory: "/home/user/projects",
        Name:           "development",
    })
    if err != nil {
        log.Fatal(err)
    }

    // Create a window and split it
    window, err := session.New(ctx)
    if err != nil {
        log.Fatal(err)
    }

    pane, err := window.FirstPane(ctx)
    if err != nil {
        log.Fatal(err)
    }

    // Split the pane and execute commands
    newPane, err := pane.Split(ctx)
    if err != nil {
        log.Fatal(err)
    }

    err = newPane.SendLine(ctx, "cd /home/user/projects && ls -la")
    if err != nil {
        log.Fatal(err)
    }
}

Documentation

Contributing

Contributions are welcome! The project aims to provide complete tmux functionality through Go. Please feel free to:

  1. Report bugs or request features
  2. Submit pull requests
  3. Improve documentation
  4. Add new examples

Development Status

This library is actively developed and aims to provide complete tmux functionality. While not all tmux features are implemented yet, the core functionality is stable and ready for production use.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when a requested entity (session, window, pane, client) does not exist.

Functions

func IsInstalled

func IsInstalled() bool

Returns true if tmux is installed on the system otherwise false.

Types

type AttachSessionOptions

type AttachSessionOptions struct {
	WorkingDir    string
	DetachClients bool

	// Stdout/Stderr will be redirected to these writers if set.
	Output, Error io.Writer
}

Attach session options.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#attach-session

type CaptureOptions

type CaptureOptions struct {
	EscTxtNBgAttr    bool
	EscNonPrintables bool
	IgnoreTrailing   bool
	PreserveTrailing bool
	PreserveAndJoin  bool
}

Capture pane command options.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#capture-pane

type ChooseTreeOptions

type ChooseTreeOptions struct {
	SessionsCollapsed bool
	WindowsCollapsed  bool
}

Choose tree options.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#choose-tree

type Client

type Client struct {
	// Activity is the time of client last activity as a Unix timestamp.
	Activity string
	// CellHeight is the height of each cell in pixels.
	CellHeight int
	// CellWidth is the width of each cell in pixels.
	CellWidth int
	// ControlMode is true if the client is in control mode.
	ControlMode bool
	// Created is the time the client was created as a Unix timestamp.
	Created string
	// Discarded contains bytes discarded when the client is not keeping up.
	Discarded string
	// Flags contains the client flags.
	Flags string
	// Height is the client terminal height in cells.
	Height int
	// KeyTable is the current key table of the client.
	KeyTable string
	// LastSession is the name of the client's last session.
	LastSession string
	// Name is the client name.
	Name string
	// Pid is the process ID of the client.
	Pid int32
	// Prefix is true if the prefix key has been pressed.
	Prefix bool
	// Readonly is true if the client is read-only.
	Readonly bool
	// Session is the name of the client's attached session.
	Session string
	// Termname is the terminal name of the client.
	Termname string
	// Termfeatures contains the terminal features of the client.
	Termfeatures string
	// Termtype is the terminal type of the client.
	Termtype string
	// Tty is the pseudo-terminal path of the client.
	Tty string
	// Uid is the user ID of the client.
	Uid int32
	// User is the username of the client.
	User string
	// Utf8 is true if the client supports UTF-8.
	Utf8 bool
	// Width is the client terminal width in cells.
	Width int
	// Written contains bytes written to the client.
	Written string
	// contains filtered or unexported fields
}

Client represents a tmux client (an attached terminal).

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#Variable

func (*Client) GetSession

func (c *Client) GetSession(ctx context.Context) (*Session, error)

GetSession returns the session that this client is attached to. Returns ErrNotFound if the session no longer exists.

type DetachClientOptions

type DetachClientOptions struct {
	TargetClient  string
	TargetSession string
}

Options object for detaching a session.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#detach-client

type NewWindowOptions

type NewWindowOptions struct {
	StartDirectory string
	WindowName     string
	DoNotAttach    bool
}

New window options.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#new-window

type Option

type Option struct {
	// Key is the option name.
	Key string
	// Value is the option value.
	Value string
}

Option represents a tmux option which is a key-value pair.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#OPTIONS

type Pane

type Pane struct {
	// Active is true if this is the current pane in its window.
	Active bool
	// AtBottom is true if this pane is at the bottom of the window.
	AtBottom bool
	// AtLeft is true if this pane is at the left of the window.
	AtLeft bool
	// AtRight is true if this pane is at the right of the window.
	AtRight bool
	// AtTop is true if this pane is at the top of the window.
	AtTop bool
	// Bg is the pane background color.
	Bg string
	// Bottom is the bottom coordinate of the pane.
	Bottom string
	// CurrentCommand is the name of the currently running command in this pane.
	CurrentCommand string
	// CurrentPath is the current working directory of the pane.
	CurrentPath string
	// Dead is true if the pane is dead (process has exited).
	Dead bool
	// DeadSignal is the signal that killed the pane process.
	DeadSignal int
	// DeadStatus is the exit status of the dead pane process.
	DeadStatus int
	// DeadTime is the time the pane process died as a Unix timestamp.
	DeadTime string
	// Fg is the pane foreground color.
	Fg string
	// Format indicates if the format variables are being used.
	Format bool
	// Height is the pane height in cells.
	Height int
	// Id is the unique pane identifier (e.g., "%0").
	Id string
	// InMode is true if the pane is in a mode (e.g., copy mode).
	InMode bool
	// Index is the pane index in its window.
	Index int
	// InputOff is true if input to the pane is disabled.
	InputOff bool
	// Last is true if this was the last selected pane.
	Last bool
	// Left is the left coordinate of the pane.
	Left string
	// Marked is true if this pane is marked.
	Marked bool
	// MarkedSet is true if the marked pane is set in this session.
	MarkedSet bool
	// Mode is the name of the current pane mode, if any.
	Mode string
	// Path is the path of the pane (the initial working directory).
	Path string
	// Pid is the process ID of the command running in the pane.
	Pid int32
	// Pipe is true if the pane is piped to a command.
	Pipe bool
	// Right is the right coordinate of the pane.
	Right string
	// SearchString is the current search string in copy mode.
	SearchString string
	// SessionName is the name of the session containing this pane.
	SessionName string
	// StartCommand is the command the pane was started with.
	StartCommand string
	// StartPath is the path the pane was started with.
	StartPath string
	// Synchronized is true if the pane is synchronized with other panes.
	Synchronized bool
	// Tabs contains the tab positions in the pane.
	Tabs string
	// Title is the pane title.
	Title string
	// Top is the top coordinate of the pane.
	Top string
	// Tty is the pseudo-terminal path of the pane.
	Tty string
	// UnseenChanges is true if the pane has unseen changes.
	UnseenChanges bool
	// Width is the pane width in cells.
	Width int
	// WindowIndex is the index of the window containing this pane.
	WindowIndex int
	// contains filtered or unexported fields
}

Pane represents a tmux pane.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#Variable

func (*Pane) Capture

func (p *Pane) Capture(ctx context.Context) (string, error)

Captures the pane with background and text atrributes escaped. Shorthand for `CapturePane`.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#capture-pane

func (*Pane) CapturePane

func (p *Pane) CapturePane(ctx context.Context, op *CaptureOptions) (string, error)

Captures the content of the pane

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#capture-pane

func (*Pane) ChooseTree

func (p *Pane) ChooseTree(ctx context.Context, op *ChooseTreeOptions) error

Puts the pane in choose tree mode.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#choose-tree

func (*Pane) DeleteOption

func (p *Pane) DeleteOption(ctx context.Context, key string) error

Deletes an option from this pane.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#set-option

func (*Pane) Kill

func (p *Pane) Kill(ctx context.Context) error

Kills the pane.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#kill-pane

func (*Pane) Option

func (p *Pane) Option(ctx context.Context, key string) (*Option, error)

Retrieves an option from this pane.

https://man.openbsd.org/OpenBSD-current/man1/tmux.1#show-options

func (*Pane) Options

func (p *Pane) Options(ctx context.Context) ([]*Option, error)

Retrieves all options in this pane.

https://man.openbsd.org/OpenBSD-current/man1/tmux.1#show-options

func (*Pane) Select

func (p *Pane) Select(ctx context.Context) error

Selects the pane with the provided options. Shorthand 'SelectPane' but with default options.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#select-pane

func (*Pane) SelectPane

func (p *Pane) SelectPane(ctx context.Context, op *SelectPaneOptions) error

Selects the pane with the provided options.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#select-pane

func (*Pane) SendKeys

func (p *Pane) SendKeys(ctx context.Context, line string) error

Pane send-keys.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#send-keys

func (*Pane) SendLine

func (p *Pane) SendLine(ctx context.Context, line string) error

SendLine sends keys to the pane and presses Enter. Shorthand for SendKeys(line) followed by SendKeys("Enter").

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#send-keys

func (*Pane) SetOption

func (p *Pane) SetOption(ctx context.Context, key, option string) error

Sets an option with a given key. Note that custom options must begin with '@'.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#set-option

func (*Pane) Split

func (p *Pane) Split(ctx context.Context) (*Pane, error)

Split the window (pane) and return the new pane. Shorthand for 'SplitWindow' but with default options.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#split-window

func (*Pane) SplitWindow

func (p *Pane) SplitWindow(ctx context.Context, op *SplitWindowOptions) (*Pane, error)

Split the window (pane) and return the new pane.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#split-window

type PanePosition

type PanePosition string

Pane relative position.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#select-pane

const (
	PanePositionUp    PanePosition = "-U"
	PanePositionRight PanePosition = "-R"
	PanePositionDown  PanePosition = "-D"
	PanePositionLeft  PanePosition = "-L"
)

Enumeration of pane positions.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#select-pane

type PaneSplitDirection

type PaneSplitDirection string

Pane split direction.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#split-window

const (
	PaneSplitDirectionHorizontal PaneSplitDirection = "-h"
	PaneSplitDirectionVertical   PaneSplitDirection = "-v"
)

Enumeration of pane split directions.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#split-window

type SelectPaneOptions

type SelectPaneOptions struct {
	TargetPosition PanePosition
}

Options for select pane.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#select-pane

type Server

type Server struct {
	// Pid is the process ID of the tmux server.
	Pid int32
	// Socket is the socket used to communicate with the server.
	Socket *Socket
	// StartTime is the time the server was started as a Unix timestamp.
	StartTime string
	// Uid is the user ID of the server process.
	Uid string
	// User is the username of the server process.
	User string
	// Version is the tmux version string.
	Version string
	// contains filtered or unexported fields
}

Server represents the tmux server.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#Variable

type Session

type Session struct {
	// Activity is the time of session last activity as a Unix timestamp.
	Activity string
	// Alerts contains window alert flags for the session.
	Alerts string
	// Attached is the number of clients attached to this session.
	Attached int
	// AttachedList is a list of clients attached to this session.
	AttachedList []string
	// Created is the time the session was created as a Unix timestamp.
	Created string
	// Format indicates if the format variables are being used.
	Format bool
	// Group is the name of the session group, if any.
	Group string
	// GroupAttached is the number of clients attached to sessions in this group.
	GroupAttached int
	// GroupAttachedList is a list of clients attached to sessions in this group.
	GroupAttachedList []string
	// GroupList is a list of sessions in this group.
	GroupList []string
	// GroupManyAttached is true if multiple clients are attached to sessions in this group.
	GroupManyAttached bool
	// GroupSize is the number of sessions in this group.
	GroupSize int
	// Grouped is true if this session is part of a group.
	Grouped bool
	// Id is the unique session identifier (e.g., "$0").
	Id string
	// LastAttached is the time the session was last attached as a Unix timestamp.
	LastAttached string
	// ManyAttached is true if multiple clients are attached to this session.
	ManyAttached bool
	// Marked is true if this session contains the marked pane.
	Marked bool
	// Name is the session name.
	Name string
	// Path is the working directory for new panes in this session.
	Path string
	// Stack is the window stack order in this session.
	Stack string
	// Windows is the number of windows in this session.
	Windows int
	// contains filtered or unexported fields
}

Session represents a tmux session.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#Variable

func (*Session) Attach

func (s *Session) Attach(ctx context.Context) error

Attaches the current client to the session. Since this requires a client, it will attach to the terminal by redirecting. Shorthand for 'AttachSession', but with default configuration.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#attach-session

func (*Session) AttachSession

func (s *Session) AttachSession(ctx context.Context, op *AttachSessionOptions) error

Attaches the current client to the session. Since this requires a client, it will attach to the terminal by redirecting. Provides the option to pipe output and error to a custom location.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#attach-session

func (*Session) DeleteOption

func (s *Session) DeleteOption(ctx context.Context, key string) error

Deletes an option from this session.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#set-option

func (*Session) Detach

func (s *Session) Detach(ctx context.Context) error

Detaches all clients attached to this session.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#detach-client

func (*Session) FirstPane

func (s *Session) FirstPane(ctx context.Context) (*Pane, error)

FirstPane returns the first pane of the first window. Convenience method for the common case of accessing the default pane.

func (*Session) GetWindowByIndex

func (s *Session) GetWindowByIndex(ctx context.Context, idx int) (*Window, error)

GetWindowByIndex returns the window at the given index in this session. Returns ErrNotFound if no window at that index exists.

func (*Session) GetWindowByName

func (s *Session) GetWindowByName(ctx context.Context, name string) (*Window, error)

GetWindowByName returns the window with the given name in this session. Returns ErrNotFound if no window with that name exists.

func (*Session) Kill

func (s *Session) Kill(ctx context.Context) error

Kills the session.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#kill-session

func (*Session) ListClients

func (s *Session) ListClients(ctx context.Context) ([]*Client, error)

List clients attached to this session.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#list-clients

func (*Session) ListPanes

func (s *Session) ListPanes(ctx context.Context) ([]*Pane, error)

List panes for this session.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#list-panes

func (*Session) ListWindows

func (s *Session) ListWindows(ctx context.Context) ([]*Window, error)

Lists all windows for this session.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#list-windows

func (*Session) New

func (s *Session) New(ctx context.Context) (*Window, error)

Creates a new window in this session. Shorthand for 'NewWindow', but with default options.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#new-window

func (*Session) NewWindow

func (s *Session) NewWindow(ctx context.Context, op *NewWindowOptions) (*Window, error)

Creates a new window in this session.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#new-window

func (*Session) NextWindow

func (s *Session) NextWindow(ctx context.Context) error

Selects the next window.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#next-window

func (*Session) Option

func (s *Session) Option(ctx context.Context, key string) (*Option, error)

Retrieves an option from this session.

https://man.openbsd.org/OpenBSD-current/man1/tmux.1#show-options

func (*Session) Options

func (s *Session) Options(ctx context.Context) ([]*Option, error)

Retrieves all options in this session.

https://man.openbsd.org/OpenBSD-current/man1/tmux.1#show-options

func (*Session) Pane

func (s *Session) Pane(ctx context.Context, windowIdx, paneIdx int) (*Pane, error)

Pane returns a pane by window and pane index. Returns ErrNotFound if either the window or pane index is out of bounds.

func (*Session) PreviousWindow

func (s *Session) PreviousWindow(ctx context.Context) error

Selects the previous window.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#previous-window

func (*Session) Rename

func (s *Session) Rename(ctx context.Context, name string) error

Renames the session to a new name.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#rename-session

func (*Session) SetOption

func (s *Session) SetOption(ctx context.Context, key, option string) error

Sets an option with a given key. Note that custom options must begin with '@'.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#set-option

type SessionOptions

type SessionOptions struct {
	Name           string
	ShellCommand   string
	StartDirectory string
	Width          int
	Height         int
}

Options object for creating a session.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#new-session

type Socket

type Socket struct {
	// Path is the filesystem path to the socket.
	Path string
}

Socket represents a tmux socket used to communicate with the server.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#S

type SplitWindowOptions

type SplitWindowOptions struct {
	SplitDirection PaneSplitDirection
	StartDirectory string
	ShellCommand   string
}

Split window options.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#split-window

type SwitchClientOptions

type SwitchClientOptions struct {
	TargetSession string
	TargetClient  string
}

Switch Client command options

type Tmux

type Tmux struct {
	Socket *Socket
}

Entrypoint object to the library.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#DESCRIPTION

func Default

func Default() (*Tmux, error)

Default initializes the tmux client with the default socket.

func New

func New(socketPath string) (*Tmux, error)

New initializes the tmux client with a socket path.

func (*Tmux) Command

func (t *Tmux) Command(ctx context.Context, cmd ...string) (string, error)

Runs a tmux command. For custom commands that the API does not cover.

func (*Tmux) DeleteOption

func (t *Tmux) DeleteOption(ctx context.Context, target, key, level string) error

Deletes an option from this session.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#set-option

func (*Tmux) DetachClient

func (t *Tmux) DetachClient(ctx context.Context, op *DetachClientOptions) error

Detaches current client, a target client or all the clients of a target session.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#detach-client

func (*Tmux) GetClient

func (t *Tmux) GetClient(ctx context.Context) (*Client, error)

GetClient returns the currently active client. Returns ErrNotFound if no client is active (e.g., when running outside tmux).

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#display-message

func (*Tmux) GetClientByTty

func (t *Tmux) GetClientByTty(ctx context.Context, tty string) (*Client, error)

GetClientByTty returns the client with the given tty. Returns ErrNotFound if no client with that tty exists.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#client_tty

func (*Tmux) GetPaneById

func (t *Tmux) GetPaneById(ctx context.Context, id string) (*Pane, error)

GetPaneById returns the pane with the given Id. Returns ErrNotFound if no pane with that id exists.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#pane_id

func (*Tmux) GetServerInformation

func (t *Tmux) GetServerInformation(ctx context.Context) (*Server, error)

Get server information.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#Variable

func (*Tmux) GetSessionByName

func (t *Tmux) GetSessionByName(ctx context.Context, name string) (*Session, error)

GetSessionByName returns the session with the given name. Returns ErrNotFound if no session with that name exists.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#session_name

func (*Tmux) GetWindowById

func (t *Tmux) GetWindowById(ctx context.Context, id string) (*Window, error)

GetWindowById returns the window with the given Id. Returns ErrNotFound if no window with that id exists.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#window_id

func (*Tmux) HasSession

func (t *Tmux) HasSession(ctx context.Context, session string) bool

Returns true if the session exists, false otherwise.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#has-session

func (*Tmux) KillServer

func (t *Tmux) KillServer(ctx context.Context) error

Kills the server. Kills all clients and servers.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#kill-server

func (*Tmux) ListAllPanes

func (t *Tmux) ListAllPanes(ctx context.Context) ([]*Pane, error)

Lists all panes in the server.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#list-panes

func (*Tmux) ListAllWindows

func (t *Tmux) ListAllWindows(ctx context.Context) ([]*Window, error)

Lists all windows.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#list-windows

func (*Tmux) ListClients

func (t *Tmux) ListClients(ctx context.Context) ([]*Client, error)

List all clients.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#list-clients

func (*Tmux) ListSessions

func (t *Tmux) ListSessions(ctx context.Context) ([]*Session, error)

List sessions.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#list-sessions

func (*Tmux) New

func (w *Tmux) New(ctx context.Context) (*Session, error)

Creates a new session without attaching. Shorthand for 'NewSession', but with default options.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#new-session

func (*Tmux) NewSession

func (t *Tmux) NewSession(ctx context.Context, op *SessionOptions) (*Session, error)

Creates a new session without attaching to it. Pass nil to create a session with default options.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#new-session

func (*Tmux) Option

func (t *Tmux) Option(ctx context.Context, target, key, level string) (*Option, error)

Retrieves an option.

https://man.openbsd.org/OpenBSD-current/man1/tmux.1#show-options

func (*Tmux) Options

func (t *Tmux) Options(ctx context.Context, target, level string) ([]*Option, error)

Retrieves all options with provided params.

https://man.openbsd.org/OpenBSD-current/man1/tmux.1#show-options

func (*Tmux) Session

func (t *Tmux) Session(ctx context.Context, name string) (*Session, error)

Gets a session by name. Shorthand for `GetSessionByName`.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#session_name

func (*Tmux) SetOption

func (t *Tmux) SetOption(ctx context.Context, target, key, option, level string) error

Sets an option at the target with given key. level can be one of:

-p (pane), -w (window), -s (server) or empty (session)

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#set-option

func (*Tmux) SwitchClient

func (t *Tmux) SwitchClient(ctx context.Context, op *SwitchClientOptions) error

Switches client to TargetSession for a TargetClient.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#switch-client

type Window

type Window struct {
	// Active is true if this is the current window in its session.
	Active bool
	// ActiveClients is the number of clients viewing this window.
	ActiveClients int
	// ActiveClientsList is a list of clients viewing this window.
	ActiveClientsList []string
	// ActiveSessions is the number of sessions on which this window is active.
	ActiveSessions int
	// ActiveSessionsList is a list of sessions on which this window is active.
	ActiveSessionsList []string
	// Activity is the time of window last activity as a Unix timestamp.
	Activity string
	// ActivityFlag is true if the window has activity alert.
	ActivityFlag bool
	// BellFlag is true if the window has bell alert.
	BellFlag bool
	// Bigger is true if the window is larger than the client.
	Bigger bool
	// CellHeight is the height of each cell in pixels.
	CellHeight int
	// CellWidth is the width of each cell in pixels.
	CellWidth int
	// EndFlag is true if this is the last window.
	EndFlag bool
	// Flags contains the window flags.
	Flags string
	// Format indicates if the format variables are being used.
	Format bool
	// Height is the window height in cells.
	Height int
	// Id is the unique window identifier (e.g., "@0").
	Id string
	// Index is the window index in the session.
	Index int
	// LastFlag is true if this was the last selected window.
	LastFlag bool
	// Layout is the window layout description.
	Layout string
	// Linked is true if the window is linked to multiple sessions.
	Linked bool
	// LinkedSessions is the number of sessions this window is linked to.
	LinkedSessions int
	// LinkedSessionsList is a list of sessions this window is linked to.
	LinkedSessionsList []string
	// MarkedFlag is true if this window contains the marked pane.
	MarkedFlag bool
	// Name is the window name.
	Name string
	// OffsetX is the horizontal offset into the visible window.
	OffsetX int
	// OffsetY is the vertical offset into the visible window.
	OffsetY int
	// Panes is the number of panes in this window.
	Panes int
	// RawFlags contains the raw window flags string.
	RawFlags string
	// SilenceFlag indicates if the window has silence alert (duration in seconds).
	SilenceFlag int
	// StackIndex is the window position in the window stack.
	StackIndex int
	// StartFlag is true if this is the first window.
	StartFlag bool
	// VisibleLayout is the visible window layout description.
	VisibleLayout string
	// Width is the window width in cells.
	Width int
	// ZoomedFlag is true if the window is zoomed.
	ZoomedFlag bool
	// contains filtered or unexported fields
}

Window represents a tmux window.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#Variable

func (*Window) DeleteOption

func (w *Window) DeleteOption(ctx context.Context, key string) error

Deletes an option from this window.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#set-option

func (*Window) FirstPane

func (w *Window) FirstPane(ctx context.Context) (*Pane, error)

FirstPane returns the first pane of this window.

func (*Window) GetPaneByIndex

func (w *Window) GetPaneByIndex(ctx context.Context, idx int) (*Pane, error)

GetPaneByIndex returns the pane at the given index in this window. Returns ErrNotFound if no pane at that index exists.

func (*Window) Kill

func (w *Window) Kill(ctx context.Context) error

Kills the window.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#kill-window

func (*Window) ListActiveClients

func (w *Window) ListActiveClients(ctx context.Context) ([]*Client, error)

ListActiveClients returns the clients viewing this window. Clients that no longer exist are silently skipped.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#window_active_clients_list

func (*Window) ListActiveSessions

func (w *Window) ListActiveSessions(ctx context.Context) ([]*Session, error)

ListActiveSessions returns the sessions on which this window is active. Sessions that no longer exist are silently skipped.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#window_active_sessions_list

func (*Window) ListLinkedSessions

func (w *Window) ListLinkedSessions(ctx context.Context) ([]*Session, error)

ListLinkedSessions returns the sessions linked to this window. Sessions that no longer exist are silently skipped.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#window_linked_sessions_list

func (*Window) ListPanes

func (w *Window) ListPanes(ctx context.Context) ([]*Pane, error)

List panes for this window.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#list-panes

func (*Window) Move

func (w *Window) Move(ctx context.Context, targetSession string, targetIdx int) error

Move this window to a different location. This will return an error if the window already exists.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#move-window

func (*Window) Option

func (w *Window) Option(ctx context.Context, key string) (*Option, error)

Retrieves an option from this window.

https://man.openbsd.org/OpenBSD-current/man1/tmux.1#show-options

func (*Window) Options

func (w *Window) Options(ctx context.Context) ([]*Option, error)

Retrieves all options in this window.

https://man.openbsd.org/OpenBSD-current/man1/tmux.1#show-options

func (*Window) Rename

func (w *Window) Rename(ctx context.Context, newName string) error

Renames a window.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#rename-window

func (*Window) Select

func (w *Window) Select(ctx context.Context) error

Selects this window.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#select-window

func (*Window) SelectLayout

func (w *Window) SelectLayout(ctx context.Context, layout WindowLayout) error

Selects the layout for this window.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#select-layout

func (*Window) SetOption

func (w *Window) SetOption(ctx context.Context, key, option string) error

Sets an option with a given key. Note that custom options must begin with '@'.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#set-option

func (*Window) Split

func (w *Window) Split(ctx context.Context) (*Pane, error)

Splits the active pane of this window and returns the new pane. Shorthand for 'SplitWindow' but with default options.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#split-window

func (*Window) SplitWindow

func (w *Window) SplitWindow(ctx context.Context, op *SplitWindowOptions) (*Pane, error)

Splits the active pane of this window and returns the new pane.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#split-window

type WindowLayout

type WindowLayout string

Window layout.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#WINDOWS_AND_PANES

const (
	WindowLayoutEvenHorizontal WindowLayout = "even-horizontal"
	WindowLayoutEvenVertical   WindowLayout = "even-vertical"
	WindowLayoutMainHorizontal WindowLayout = "main-horizontal"
	WindowLayoutMainVertical   WindowLayout = "main-vertical"
	WindowLayoutTiled          WindowLayout = "tiled"
)

Enumeration of window layouts.

Reference: https://man.openbsd.org/OpenBSD-current/man1/tmux.1#WINDOWS_AND_PANES

Directories

Path Synopsis
examples
create command
get_server_info command
list_clients command
listing command
sessions command
windows_panes command

Jump to

Keyboard shortcuts

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