tmuxutils

package
v0.448.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

README

tmuxutils

Helper functions to orchestrate tmux.

An example usage to orchestrate the input to another binary can be found in the TestTemuxWindow_WaitOutputMatchesRegex defined in TmuxWindow_test.go.

For developers

Run tests:

bash -c "cd '$(git rev-parse --show-toplevel)' && go test -v ./pkg/tmuxutils/..."

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTmuxWindowCliPromptNotReady = errors.New("tmux window CLI promptnot ready")

Functions

func IsTmuxKey

func IsTmuxKey(input string) (isKey bool)

Returns true if input string is a valid tmux key like "enter". Returns false otherwise.

Types

type TmuxService

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

func GetTmuxOnLocalMachine

func GetTmuxOnLocalMachine() (tmux *TmuxService, err error)

func NewTmuxService

func NewTmuxService() (t *TmuxService)

func (*TmuxService) GetCommandExecutor

func (t *TmuxService) GetCommandExecutor() (commandExecutor commandexecutorinterfaces.CommandExecutor, err error)

func (*TmuxService) GetSessionByName

func (t *TmuxService) GetSessionByName(name string) (tmuxSession *TmuxSession, err error)

func (*TmuxService) GetWindowByNames

func (t *TmuxService) GetWindowByNames(sessionName string, windowName string) (window *TmuxWindow, err error)

func (*TmuxService) ListSessionNames

func (t *TmuxService) ListSessionNames(ctx context.Context) (sessionNames []string, err error)

func (*TmuxService) SetCommandExecutor

func (t *TmuxService) SetCommandExecutor(commandExecutor commandexecutorinterfaces.CommandExecutor) (err error)

type TmuxSession

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

func NewTmuxSession

func NewTmuxSession() (t *TmuxSession)

func (*TmuxSession) Create

func (t *TmuxSession) Create(ctx context.Context) (err error)

func (*TmuxSession) Delete

func (t *TmuxSession) Delete(ctx context.Context) (err error)

func (*TmuxSession) Exists

func (t *TmuxSession) Exists(ctx context.Context) (exists bool, err error)

func (*TmuxSession) GetCommandExecutor

func (t *TmuxSession) GetCommandExecutor() (commandExecutor commandexecutorinterfaces.CommandExecutor, err error)

func (*TmuxSession) GetName

func (t *TmuxSession) GetName() (name string, err error)

func (*TmuxSession) GetTmux

func (t *TmuxSession) GetTmux() (tmux *TmuxService, err error)

func (*TmuxSession) GetWindowByName

func (t *TmuxSession) GetWindowByName(windowName string) (window *TmuxWindow, err error)

func (*TmuxSession) ListWindowNames

func (t *TmuxSession) ListWindowNames(ctx context.Context) (windowsNames []string, err error)

func (*TmuxSession) Recreate

func (t *TmuxSession) Recreate(ctx context.Context) (err error)

func (*TmuxSession) SetName

func (t *TmuxSession) SetName(name string) (err error)

func (*TmuxSession) SetTmux

func (t *TmuxSession) SetTmux(tmux *TmuxService) (err error)

type TmuxWindow

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

func NewTmuxWindow

func NewTmuxWindow() (t *TmuxWindow)

func (*TmuxWindow) Create

func (t *TmuxWindow) Create(ctx context.Context) (err error)

func (*TmuxWindow) Delete

func (t *TmuxWindow) Delete(ctx context.Context) (err error)

func (*TmuxWindow) DeleteSession

func (t *TmuxWindow) DeleteSession(ctx context.Context) (err error)

Delete the tmux session this window belongs to. Will implicitly also kill this window but also any other window in the session.

func (*TmuxWindow) Exists

func (t *TmuxWindow) Exists(ctx context.Context) (exists bool, err error)

func (*TmuxWindow) GetCommandExecutor

func (t *TmuxWindow) GetCommandExecutor() (commandExecutor commandexecutorinterfaces.CommandExecutor, err error)

func (*TmuxWindow) GetLatestPaneLine

func (t *TmuxWindow) GetLatestPaneLine() (paneLine string, err error)

func (*TmuxWindow) GetName

func (t *TmuxWindow) GetName() (name string, err error)

func (*TmuxWindow) GetSecondLatestPaneLine

func (t *TmuxWindow) GetSecondLatestPaneLine() (paneLine string, err error)

Since the latest line usually shows the command prompt this command can be used to receive the latest printed line.

func (*TmuxWindow) GetSession

func (t *TmuxWindow) GetSession() (session *TmuxSession, err error)

func (*TmuxWindow) GetSessionAndWindowName

func (t *TmuxWindow) GetSessionAndWindowName() (sessionName string, windowName string, err error)

func (*TmuxWindow) GetSessionName

func (t *TmuxWindow) GetSessionName() (sessionName string, err error)

func (*TmuxWindow) GetShownLines

func (t *TmuxWindow) GetShownLines() (lines []string, err error)

func (*TmuxWindow) GetShownOutput

func (t *TmuxWindow) GetShownOutput() (output string, err error)

func (*TmuxWindow) IsOutputMatchingRegex

func (t *TmuxWindow) IsOutputMatchingRegex(ctx context.Context, regex string) (isMatching bool, err error)

func (*TmuxWindow) ListWindowNames

func (t *TmuxWindow) ListWindowNames(ctx context.Context) (windowNames []string, err error)

func (*TmuxWindow) Recreate

func (t *TmuxWindow) Recreate(ctx context.Context) (err error)

func (*TmuxWindow) RunCommand

func (t *TmuxWindow) RunCommand(ctx context.Context, runCommandOptions *parameteroptions.RunCommandOptions) (commandOutput *commandoutput.CommandOutput, err error)

func (*TmuxWindow) SendKeys

func (t *TmuxWindow) SendKeys(ctx context.Context, toSend []string) (err error)

Default use case to send a command is using []string{"command to run", "enter"}. "enter" in this example is detected as enter key by tmux.

func (*TmuxWindow) SetName

func (t *TmuxWindow) SetName(name string) (err error)

func (*TmuxWindow) SetSession

func (t *TmuxWindow) SetSession(session *TmuxSession) (err error)

func (*TmuxWindow) WaitUntilCliPromptReady

func (t *TmuxWindow) WaitUntilCliPromptReady(ctx context.Context) (err error)

func (*TmuxWindow) WaitUntilOutputMatchesRegex

func (t *TmuxWindow) WaitUntilOutputMatchesRegex(ctx context.Context, regex string, timeout time.Duration) (err error)

Jump to

Keyboard shortcuts

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