client

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultConfigFile = ".jig.yml"

Variables

View Source
var (
	ErrConfigNotFound   = errors.New("project file not found")
	ErrEditorNotFound   = errors.New("editor not found")
	ErrNoWindowsFound   = errors.New("no windows found")
	ErrNoSessionName    = errors.New("you must specify a session name")
	ErrNotInsideSession = errors.New("cannot use -i flag outside of a tmux session")
)

Functions

func EditFile

func EditFile(path string) error

EditFile launches the default editor to edit a specified file.

func FindConfig

func FindConfig(dir, project string) (string, error)

FindConfig finds the config filename in the specified directory.

func GetConfigPath

func GetConfigPath() (string, error)

GetConfigPath returns the default base config path.

func GetEditor

func GetEditor() (string, error)

GetEditor returns the editor to use.

func ListConfigs

func ListConfigs(dir string) ([]string, error)

ListConfigs returns a list of config files in the specified directory.

Types

type Config

type Config struct {
	Session         string            `yaml:"session"`
	Env             map[string]string `yaml:"env,omitempty"`
	Path            string            `yaml:"path"`
	Before          []string          `yaml:"before,omitempty"`
	After           []string          `yaml:"after,omitempty"`
	Windows         []Window          `yaml:"windows"`
	CommandDelay    int               `yaml:"command_delay,omitempty"`
	SuppressHistory bool              `yaml:"suppress_history,omitempty"`
	Sessions        []Config          `yaml:"sessions,omitempty"`

	ConfigPath string `yaml:"config_path,omitempty"`
}

func LoadConfig

func LoadConfig(path string, vars map[string]string) (Config, error)

LoadConfig reads an entire config file, parses it with supplied variables, adds default environment variables and returns the final config.

func RenderConfig

func RenderConfig(data string, vars map[string]string) (Config, error)

RenderConfig renders contents with supplied variables.

func (Config) GetSessionPath added in v0.1.1

func (c Config) GetSessionPath() (string, error)

type Jig

type Jig struct {
	Tmux      tmux.TmuxClient
	Theme     Theme
	Options   Options
	InSession bool
}

func New

func New(opts Options, commander shell.Commander) (Jig, error)

New creates a new Jig client.

func (Jig) GenerateSessionConfig

func (j Jig) GenerateSessionConfig(sessionName string) (Config, error)

GenerateSessionConfig creates a Config object from a tmux session.

func (Jig) Start

func (j Jig) Start(config Config, windows []string) error

Start starts a new tmux session, any nested sessions, run optional `before` command and optionally attach to the first session.

func (Jig) Stop

func (j Jig) Stop(config Config, windows []string) error

Stop stops a tmux session and its nested sessions, if any.

func (Jig) SwitchOrAttach

func (j Jig) SwitchOrAttach(session string) error

SwitchOrAttach switches to a tmux session or attaches to it if it exists.

type Options

type Options struct {
	Debug    bool   `help:"Print all commands to ~/.cache/jig.log"`
	File     string `help:"Custom path to a config file." short:"f"`
	Detach   bool   `help:"Do not attach to the session." short:"d"`
	Inside   bool   `help:"Create windows inside current session." short:"i"`
	TmuxPath string
}

type Pane

type Pane struct {
	Type     string   `yaml:"type,omitempty"`
	Path     string   `yaml:"path,omitempty"`
	Focus    bool     `yaml:"focus,omitempty"`
	Commands []string `yaml:"commands,omitempty"`
	Cmd      string   `yaml:"cmd,omitempty"`
}

func (Pane) GetCommands added in v0.1.2

func (p Pane) GetCommands() []string

type Theme

type Theme struct {
	ID       lipgloss.Style
	Date     lipgloss.Style
	Attached lipgloss.Style
	Marked   lipgloss.Style
	Activity lipgloss.Style
	Windows  lipgloss.Style

	IconMarked   string
	IconAttached string
	IconTmux     string
	IconAlert    string

	FzfArgs []string
}

func NewThemeDefault

func NewThemeDefault() Theme

NewThemeDefault returns the default theme.

type Window

type Window struct {
	Name     string   `yaml:"name"`
	Before   []string `yaml:"before,omitempty"`
	Panes    []Pane   `yaml:"panes,omitempty"`
	Layout   string   `yaml:"layout"`
	Focus    bool     `yaml:"focus,omitempty"`
	Manual   bool     `yaml:"manual,omitempty"`
	Path     string   `yaml:"path,omitempty"`
	Commands []string `yaml:"commands,omitempty"`
	Cmd      string   `yaml:"cmd,omitempty"`
}

func (Window) GetCommands added in v0.1.2

func (w Window) GetCommands() []string

Jump to

Keyboard shortcuts

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