kitty

package
v0.0.0-...-59fc95b Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package kitty provides a client for interacting with the kitty terminal emulator's remote control features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	To string // Same --to option as kitty @ commands. If empty, uses KITTY_LISTEN_ON env var.
	// contains filtered or unexported fields
}

Client is a kitty remote control client. Currently, it uses a single connection. Future versions may support a pool, but this works well enough for now.

func (*Client) CloseWindow

func (c *Client) CloseWindow(ctx context.Context, match string) error

func (*Client) DetachWindow

func (c *Client) DetachWindow(ctx context.Context, p *DetachWindowParams) error

func (*Client) FocusWindow

func (c *Client) FocusWindow(ctx context.Context, match string) error

func (*Client) GetText

func (c *Client) GetText(ctx context.Context, match string, p *GetTextParams) (string, error)

func (*Client) Launch

func (c *Client) Launch(ctx context.Context, p *LaunchParams) (string, error)

Launch creates a new window or tab and returns the window ID.

func (*Client) List

func (c *Client) List(ctx context.Context, p *ListParams) (*State, error)

func (*Client) SetTabTitle

func (c *Client) SetTabTitle(ctx context.Context, p *SetTabTitleParams) error

func (*Client) SetUserVars

func (c *Client) SetUserVars(ctx context.Context, p *SetUserVarsParams) error

type CommonParams

type CommonParams struct {
	Match string `json:"match,omitempty"`
}

type DetachWindowParams

type DetachWindowParams struct {
	Match     string `json:"match,omitempty"`
	TargetTab string `json:"target_tab,omitempty"`
	TabTitle  string `json:"tab_title,omitempty"`
}

type Error

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

func (*Error) Error

func (e *Error) Error() string

func (*Error) Traceback

func (e *Error) Traceback() string

type ForegroundProcess

type ForegroundProcess struct {
	Cwd     string   `json:"cwd"`
	Cmdline []string `json:"cmdline"`
	Pid     int      `json:"pid"`
}

ForegroundProcess represents a process running in the foreground of a window.

type GetTextParams

type GetTextParams struct {
	Extent string `json:"extent,omitempty"`
	ANSI   bool   `json:"ansi,omitempty"`
}

type LaunchParams

type LaunchParams struct {
	Type     string `json:"type,omitempty"`
	TabTitle string `json:"tab_title,omitempty"`
}

type ListParams

type ListParams struct {
	Match         string `json:"match,omitempty"`
	MatchTab      string `json:"match_tab,omitempty"`
	IgnoreNoMatch bool   `json:"ignore_no_match,omitempty"`
}

type OSWindow

type OSWindow struct {
	ID   int
	Tabs []*Tab
}

OSWindow represents a Kitty OS Window.

type SetTabTitleParams

type SetTabTitleParams struct {
	Match string `json:"match,omitempty"`
	Title string `json:"title,omitempty"`
}

type SetUserVarsParams

type SetUserVarsParams struct {
	Match string   `json:"match,omitempty"`
	Var   []string `json:"var,omitempty"`
}

type State

type State struct {
	OSWindows []*OSWindow
}

func (*State) Windows

func (s *State) Windows() iter.Seq[*Window]

Windows returns a flattened sequence of all windows in s. Each window's Tab and OSWindow fields are set to their containing structures.

type Tab

type Tab struct {
	ID        int
	IsActive  bool `json:"is_active"`
	IsFocused bool `json:"is_focused"`
	Title     string
	Windows   []*Window
}

Tab represents a tab in an OS Window.

type Vars

type Vars map[string]string

Vars represents user-defined kitty window vars. See 'kitty @ set-user-vars'.

func (Vars) Get

func (v Vars) Get(key string) string

Get retrieves the value of the given key.

func (Vars) Has

func (v Vars) Has(key string) bool

Has reports true if the given key exists; false otherwise.

type Window

type Window struct {
	OSWindow            *OSWindow `json:"-"`
	Tab                 *Tab      `json:"-"`
	ID                  int
	Cwd                 string               `json:"cwd"`
	Title               string               `json:"title"`
	Cmdline             string               `json:"last_reported_cmdline"`
	IsSelf              bool                 `json:"is_self"`
	Vars                Vars                 `json:"user_vars"`
	AtPrompt            bool                 `json:"at_prompt"`
	CreatedAt           int64                `json:"created_at"` // Unix nanoseconds
	ForegroundProcesses []*ForegroundProcess `json:"foreground_processes"`
}

Window represents a window in a tab.

func (*Window) CreatedAtTime

func (w *Window) CreatedAtTime() time.Time

func (*Window) EffectiveCwd

func (w *Window) EffectiveCwd() string

EffectiveCwd returns the cwd of the foreground process if available, otherwise falls back to the window's cwd.

Jump to

Keyboard shortcuts

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