session

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdHocOptions

type AdHocOptions struct {
	Force     bool // destroy any existing session with the same name first
	Detach    bool // create without attaching
	Temporary bool // set destroy-unattached on the session
}

AdHocOptions tunes CreateAdHoc.

type Manager

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

Manager orchestrates session lifecycle on top of a Tmux implementation.

func NewManager

func NewManager(cfg *config.Config, logger *slog.Logger) (*Manager, error)

NewManager wires a Manager backed by a real *tmux.Client. Returns an error if tmux is not on PATH.

func NewManagerWith

func NewManagerWith(cfg *config.Config, tx tmux.Tmux, logger *slog.Logger) *Manager

NewManagerWith builds a Manager backed by the given Tmux. Used by tests.

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, name string, force bool) error

Create creates a new session without attaching.

func (*Manager) CreateAdHoc

func (m *Manager) CreateAdHoc(ctx context.Context, name string, session *config.Session, opts AdHocOptions) error

CreateAdHoc creates a session from an in-memory Session definition (i.e. not loaded from the config file). The Session is validated with the same rules as configured sessions. If temporary is true, the session is set to destroy itself when the last client detaches.

func (*Manager) CreateAdHocWindow

func (m *Manager) CreateAdHocWindow(ctx context.Context, parentSession, windowName string, sess *config.Session) error

CreateAdHocWindow creates a new window inside the named parent session (typically the current $TMUX session) and fills it with one pane per host. It does not change session focus — the caller is presumed to be inside the same tmux client and will see the new window appear.

func (*Manager) CreateOrAttach

func (m *Manager) CreateOrAttach(ctx context.Context, name string, force bool) error

CreateOrAttach attaches to an existing tmux session, or builds one from the configuration and attaches. If the session name is not in the config, the caller can still attach to it as long as it already exists in tmux — this lets `mox -a foo` work for hand-rolled tmux sessions too.

On context cancellation during build the partial session is killed.

func (*Manager) Kill

func (m *Manager) Kill(name string) error

Kill destroys a session.

func (*Manager) List

func (m *Manager) List() ([]SessionInfo, error)

List returns information about all configured sessions plus any running tmux sessions that are not in the config.

type SessionInfo

type SessionInfo struct {
	Name    string
	Running bool
	Managed bool
}

SessionInfo describes a session and whether it is currently running. Managed is true if the name appears in the mox config; false if the session exists in tmux but has no config entry.

Jump to

Keyboard shortcuts

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