tmux

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction int

Direction represents the split direction for panes.

const (
	// Horizontal splits the pane horizontally (left/right).
	Horizontal Direction = iota
	// Vertical splits the pane vertically (top/bottom).
	Vertical
)

type Pane

type Pane struct {
	Id     string `json:"id"`
	Index  int    `json:"index"`
	Active bool   `json:"active"`
}

Pane represents a tmux pane within a window.

type Server

type Server struct {
}

Server represents a tmux server instance and provides methods to interact with it.

func (*Server) AddSession

func (s *Server) AddSession(name string, path string) (Session, error)

Add session

we should guard against session names containing - the separator `:` - the char `.`

but are problematic, but since we normalize before, we should be fine

func (*Server) AddWindow

func (*Server) AddWindow(name string, path string) (string, error)

Creates a new window with the given name and starting directory Returns the unique window ID assigned by tmux

func (*Server) AttachSession

func (s *Server) AttachSession(session Session) error

AttachSession attaches to an existing session.

The behavior depends on the current tmux context:

  • Attached: switches to the session using switch-session
  • Detached: attaches to the session using attach-session
  • Serverless: switches the client to the session using switch-client

func (*Server) CurrentSession

func (s *Server) CurrentSession() (Session, error)

func (*Server) CurrentWindow

func (s *Server) CurrentWindow() (Window, error)

CurrentWindow returns the currently active window

func (*Server) HasSession

func (*Server) HasSession(name string) bool

HasSession checks if a tmux session with the given name exists. Returns true if the session exists, false otherwise.

func (*Server) ListPanes

func (*Server) ListPanes(targetWindow string) ([]Pane, error)

Lists all panes in the targeted window

func (*Server) ListSessions

func (s *Server) ListSessions(detachedOnly bool) ([]Session, error)

Lists all sessions managed by this server.

func (*Server) ListWindows

func (s *Server) ListWindows(sessionId string) ([]Window, error)

Lists all Windows of the targeted session

func (*Server) RenameWindow added in v0.9.0

func (*Server) RenameWindow(targetWindow string, newName string) error

RenameWindow renames the specified window to the given name. The target can be a window ID, window index, or window name.

func (*Server) SelectLayout added in v0.9.0

func (*Server) SelectLayout(targetWindow string, layoutType string) error

SelectLayout applies a layout to the specified window. The target can be a window ID, window index, or window name. layoutType should be one of: even-horizontal, even-vertical, main-horizontal, main-vertical, tiled.

func (*Server) SelectPane

func (*Server) SelectPane(targetPane string) error

SelectPane selects (focuses) the specified pane. The target can be a pane ID, or a pane index.

func (*Server) SelectWindow

func (*Server) SelectWindow(targetWindow string) error

SelectWindow selects (switches to) the specified window. The target can be a window ID, window index, or window name.

func (*Server) SendKeys

func (*Server) SendKeys(targetPane string, keys string) error

SendKeys sends keys/commands to the specified pane. Automatically sends Enter (C-m) after the keys.

func (*Server) SessionByName

func (s *Server) SessionByName(name string) (*Session, error)

SessionByName retrieves a Session by name.

Returns nil pointer if session not found

func (*Server) SplitPane

func (*Server) SplitPane(targetPane string, direction Direction, startDirectory string) (string, error)

SplitPane splits the specified pane and returns the new pane ID. Direction can be Horizontal (left/right) or Vertical (top/bottom).

type Session

type Session struct {
	Id       string   `json:"id"`
	Name     string   `json:"name"`
	Attached bool     `json:"attached"`
	Path     string   `json:"path"`
	Windows  []Window `json:"windows"`
}

Session represents a tmux session with its name, attachment status, and working directory.

type TmuxContext

type TmuxContext int64

TmuxContext represents the current execution context relative to tmux.

const (
	// Attached indicates the process is running inside a tmux session.
	Attached TmuxContext = iota
	// Detached indicates a tmux server is running but the process is outside any session.
	Detached
	// Serverless indicates no tmux server is currently running.
	Serverless
)

type Window

type Window struct {
	Id            string `json:"id"`
	Active        bool   `json:"active"`
	ActiveClients int    `json:"active_clients"`
	Name          string `json:"name"`
	Panes         []Pane `json:"panes"`
}

Window represents a tmux window within a session.

Jump to

Keyboard shortcuts

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