Documentation
¶
Overview ¶
Package tmux discovers and inspects tmux terminal multiplexer environments.
It provides helpers for detecting the current tmux session, window, and pane from process environment variables, listing active panes, and sending signals to panes across running tmux servers.
Index ¶
- Variables
- func ContextFromEnv(env Env) registry.TmuxContext
- func Current(ctx context.Context) (registry.TmuxContext, error)
- func CurrentWithEnv(ctx context.Context, env Env) (registry.TmuxContext, error)
- func ParseCurrent(output string) (registry.TmuxContext, error)
- func SendInterruptTo(ctx context.Context, serverIdentity, paneID string) error
- type CaptureOptions
- type CommandRunner
- type Env
- type ListOptions
- type Pane
- type ScreenSnapshot
- type ServerProcess
- type ServerProcessLister
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoTmuxContext is returned when no tmux environment is available. ErrNoTmuxContext = errors.New("not inside tmux") // ErrInvalidFieldCount is returned when tmux output does not match the requested format. ErrInvalidFieldCount = errors.New("invalid tmux field count") )
Functions ¶
func ContextFromEnv ¶
func ContextFromEnv(env Env) registry.TmuxContext
Example ¶
package main
import (
"fmt"
"github.com/zigai/aht/pkg/tmux"
)
func main() {
env := tmux.Env{
TMUX: "/tmp/tmux-1000/default,1234,0",
TMUXPane: "%0",
}
context := tmux.ContextFromEnv(env)
fmt.Printf("Inside: %t, PaneID: %s\n", context.Inside, context.PaneID)
}
Output: Inside: true, PaneID: %0
func CurrentWithEnv ¶
func ParseCurrent ¶
func ParseCurrent(output string) (registry.TmuxContext, error)
Types ¶
type CaptureOptions ¶
type CaptureOptions struct {
Env Env
Run CommandRunner
Lines int
}
type CommandRunner ¶
CommandRunner executes tmux with an explicit argv. Implementations must not invoke a shell.
type ListOptions ¶
type ListOptions struct {
Env Env
Run CommandRunner
ServerProcesses ServerProcessLister
}
ListOptions controls pane discovery and is primarily useful for observer injection and deterministic tests.
type Pane ¶
type Pane struct {
Tmux registry.TmuxContext
ServerIdentity string
PanePID int
PaneTTY string
}
func ListPanesWithOptions ¶
func ListPanesWithOptions(ctx context.Context, options ListOptions) ([]Pane, error)
func ParseListPanes ¶
type ScreenSnapshot ¶
func CapturePane ¶
func CapturePane(ctx context.Context, pane Pane) (ScreenSnapshot, error)
func CapturePaneWithOptions ¶
func CapturePaneWithOptions(ctx context.Context, pane Pane, options CaptureOptions) (ScreenSnapshot, error)
type ServerProcess ¶
ServerProcess is the current-user process snapshot used to discover custom tmux servers.
type ServerProcessLister ¶
type ServerProcessLister func(context.Context) ([]ServerProcess, error)
ServerProcessLister supplies current-user tmux server processes.
Click to show internal directories.
Click to hide internal directories.