tmux

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package tmux provides APIs to interact with the tmux(1) terminal multiplexer.

It provides a Driver interface and a ShellDriver implementation. These provides direct, low-level interaction with tmux operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CapturePaneRequest

type CapturePaneRequest struct {
	// Pane to capture. Defaults to current.
	Pane string

	// Start and end positions of the captured text. Negative lines are
	// positions in history.
	StartLine, EndLine int
}

CapturePaneRequest specifies the parameters for a capture-pane command.

func (CapturePaneRequest) String

func (r CapturePaneRequest) String() string

type DisplayMessageRequest

type DisplayMessageRequest struct {
	// Pane to capture. Defaults to current.
	Pane string

	// Message to display.
	Message string
}

DisplayMessageRequest specifies the parameters for a display-message command.

func (DisplayMessageRequest) String

func (r DisplayMessageRequest) String() string

type Driver

type Driver interface {
	// NewSession runs the tmux new-session command and returns its output.
	NewSession(NewSessionRequest) ([]byte, error)

	// DisplayMessage runs the tmux display-message command and returns its
	// output.
	DisplayMessage(DisplayMessageRequest) ([]byte, error)

	// CapturePane runs the tmux capture-pane command and returns its
	// output.
	CapturePane(CapturePaneRequest) ([]byte, error)

	// SwapPane runs the tmux swap-pane command.
	SwapPane(SwapPaneRequest) error

	// ResizePane runs the tmux resize-pane command.
	ResizePane(ResizePaneRequest) error

	// ResizeWindow runs the tmux resize-window command.
	ResizeWindow(ResizeWindowRequest) error

	// WaitForSignal runs the tmux wait-for command, waiting for a
	// corresponding SendSignal command.
	WaitForSignal(string) error

	// SendSignal runs the tmux wait-for command, activating anyone waiting
	// for this signal.
	SendSignal(string) error

	// ShowOptions runs the tmux show-options command and returns its
	// output.
	ShowOptions(ShowOptionsRequest) ([]byte, error)

	// SetOption runs the tmux set-option command.
	SetOption(SetOptionRequest) error
}

Driver is a low-level API to access tmux. This maps directly to tmux commands.

type NewSessionRequest

type NewSessionRequest struct {
	// Name of the session, if any.
	Name string

	// Output format, if any. Without this, NewSession will not return any
	// output.
	Format string

	// Size of the new window.
	Width, Height int

	// Whether the new session should be detached from this client.
	Detached bool

	// Additional environment variables to pass to the command in the new
	// session.
	Env []string

	// Command to run in this new window. Must have at least one element.
	Command []string
}

NewSessionRequest specifies the parameter for a new-session command.

func (NewSessionRequest) String

func (r NewSessionRequest) String() string

type PaneInfo

type PaneInfo struct {
	ID             string
	WindowID       string
	Width, Height  int
	Mode           PaneMode
	ScrollPosition int
	WindowZoomed   bool

	// Current path of the pane, if available.
	CurrentPath string
}

PaneInfo reports information about a tmux pane.

func InspectPane

func InspectPane(driver Driver, identifier string) (*PaneInfo, error)

InspectPane inspects a tmux pane and reports information about it. The argument identifies the pane we want to inspect, defaulting to the current pane if none is specified.

func (*PaneInfo) String

func (i *PaneInfo) String() string

type PaneMode

type PaneMode string

PaneMode specifies the mode in which the pane is.

const (
	// NormalMode specifies that the tmux pane is in normal mode, at the
	// bottom of the screen.
	NormalMode PaneMode = "normal-mode"

	// CopyMode indicates that the tmux pane is in copy mode, and may be
	// scrolled up.
	CopyMode PaneMode = "copy-mode"
)

type ResizePaneRequest added in v0.4.0

type ResizePaneRequest struct {
	Target     string // target pane
	ToggleZoom bool   // whether to toggle zoom
}

ResizePaneRequest specifies the parameters for a resize-pane command.

func (ResizePaneRequest) String added in v0.4.0

func (r ResizePaneRequest) String() string

type ResizeWindowRequest

type ResizeWindowRequest struct {
	Window        string
	Width, Height int
}

ResizeWindowRequest specifies the parameters for a resize-window command.

func (ResizeWindowRequest) String

func (r ResizeWindowRequest) String() string

type SetOptionRequest added in v0.14.0

type SetOptionRequest struct {
	// Name of the option to set.
	Name string

	// Value to set the option to.
	Value string

	// Whether this option should be changed globally.
	Global bool
}

SetOptionRequest specifies the parameters for the set-option command.

type ShellDriver

type ShellDriver struct {
	// Path to the tmux executable. Defaults to "tmux".
	Path string

	// Path to the env command. Defaults to /usr/bin/env.
	Env string
	// contains filtered or unexported fields
}

ShellDriver is a Driver implementation that shells out to tmux to run commands.

func (*ShellDriver) CapturePane

func (s *ShellDriver) CapturePane(req CapturePaneRequest) ([]byte, error)

CapturePane runs the capture-pane command and returns its output.

func (*ShellDriver) DisplayMessage

func (s *ShellDriver) DisplayMessage(req DisplayMessageRequest) ([]byte, error)

DisplayMessage displays the given message in tmux and returns its output.

func (*ShellDriver) NewSession

func (s *ShellDriver) NewSession(req NewSessionRequest) ([]byte, error)

NewSession runs the tmux new-session command.

func (*ShellDriver) ResizePane added in v0.4.0

func (s *ShellDriver) ResizePane(req ResizePaneRequest) error

ResizePane runs the resize-pane command.

func (*ShellDriver) ResizeWindow

func (s *ShellDriver) ResizeWindow(req ResizeWindowRequest) error

ResizeWindow runs the resize-window command.

func (*ShellDriver) SendSignal

func (s *ShellDriver) SendSignal(sig string) error

SendSignal runs the wait-for -S command.

func (*ShellDriver) SetLogger added in v0.3.0

func (s *ShellDriver) SetLogger(log *log.Logger)

SetLogger specifies the logger for the ShellDriver. By default, the ShellDriver does not log anything.

func (*ShellDriver) SetOption added in v0.14.0

func (s *ShellDriver) SetOption(req SetOptionRequest) error

SetOption runs the set-option command with the given parameters.

func (*ShellDriver) ShowOptions

func (s *ShellDriver) ShowOptions(req ShowOptionsRequest) ([]byte, error)

ShowOptions runs the show-options command.

func (*ShellDriver) SwapPane

func (s *ShellDriver) SwapPane(req SwapPaneRequest) error

SwapPane runs the swap-pane command.

func (*ShellDriver) WaitForSignal

func (s *ShellDriver) WaitForSignal(sig string) error

WaitForSignal runs the wait-for command.

type ShowOptionsRequest

type ShowOptionsRequest struct {
	Global bool // show global options
}

ShowOptionsRequest specifies the parameters for a show-options command.

func (ShowOptionsRequest) String

func (r ShowOptionsRequest) String() string

type SwapPaneRequest

type SwapPaneRequest struct {
	// Source pane. Defaults to current.
	Source string

	// Destination pane to swap the source with.
	Destination string
}

SwapPaneRequest specifies the parameters for a swap-pane command.

func (SwapPaneRequest) String

func (r SwapPaneRequest) String() string

Directories

Path Synopsis
Package tmuxfmt constructs tmux FORMATS compatible strings.
Package tmuxfmt constructs tmux FORMATS compatible strings.
Package tmuxopt provides an API for loading and parsing tmux options into Go variables.
Package tmuxopt provides an API for loading and parsing tmux options into Go variables.
Package tmuxtest includes utilities to test APIs defined in the tmux package.
Package tmuxtest includes utilities to test APIs defined in the tmux package.

Jump to

Keyboard shortcuts

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