termsetup

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

What the terminals icebath knows need for the terminal app to get every key it acts on, and the changes that give it to them: computed as plans from what is read, nothing written here

Index

Constants

This section is empty.

Variables

View Source
var Terminals = []Terminal{
	{ID: "vscode", Name: "VS Code", Known: "TERM_PROGRAM is vscode, or VSCODE_GIT_IPC_HANDLE is set"},
	{ID: "cursor", Name: "Cursor", Known: "CURSOR_TRACE_ID is set, or the askpass helper VS Code names is Cursor's"},
	{ID: "windsurf", Name: "Windsurf", Known: "the askpass helper VS Code names is Windsurf's"},
	{ID: "insiders", Name: "VS Code Insiders", Known: "as VS Code, the askpass helper it names being of Insiders"},
	{ID: "vscodium", Name: "VSCodium", Known: "as VS Code, the askpass helper it names being VSCodium's"},
	{ID: "alacritty", Name: "Alacritty", Known: "ALACRITTY_WINDOW_ID or ALACRITTY_SOCKET is set, or TERM is alacritty"},
	{ID: "kitty", Name: "kitty", Known: "KITTY_WINDOW_ID is set, or TERM is xterm-kitty"},
	{ID: "wezterm", Name: "WezTerm", Known: "TERM_PROGRAM is WezTerm, or WEZTERM_PANE is set"},
	{ID: "ghostty", Name: "Ghostty", Known: "TERM_PROGRAM is ghostty, or TERM is xterm-ghostty"},
	{ID: "iterm2", Name: "iTerm2", Known: "TERM_PROGRAM is iTerm.app, or LC_TERMINAL is iTerm2"},
	{ID: "apple", Name: "Terminal", Known: "TERM_PROGRAM is Apple_Terminal"},
	{ID: "windows", Name: "Windows Terminal", Known: "WT_SESSION is set"},
	{ID: "tmux", Name: "tmux", Known: "TMUX is set"},
}

Terminals the setup knows, each with how it is told to be the one the app runs in: alpha's editors of the VS Code family first, in its order, then the terminals beside them, then tmux, which runs inside another

Functions

func Apply

func Apply(ctx context.Context, plan Plan) error

Carries out the changes of a plan in order: each file copied to its backup first and written whole, keeping the permissions it had, each program run, each file of the setup's own taken away; it stops at the first that fails, saying which and what was done before it

func Remote

func Remote(sys System) bool

Whether the app runs over SSH, so a terminal's settings are on the computer the person connects from

Types

type Change

type Change struct {
	Path          string
	Before, After []byte
	Backup        string
	Run           []string
	// What the change gives the terminal, in words, such as "shift+enter breaks a line"
	Gives []string
}

One change of a plan: a file written whole, with what it holds before, nil for one not there, and after, copied first to its backup when it was there; a program run with its arguments; or, with neither After nor Run, a file of the setup's own taken away

type Plan

type Plan struct {
	Terminal Terminal
	Changes  []Change
	// Keys and abilities the terminal does not give the app as it stands, which the changes give it; none for a terminal set up already or
	// that needs nothing
	Missing []string
	// Sentences said to the person: what was found, what to do once the changes are made
	Notes []string
	// Why nothing is done, a sentence; empty for a plan that can be carried out
	Refused string
}

What the setup of a terminal does: its changes, the keys and abilities it misses as it stands, what is said to the person, and why nothing can be done where nothing can

func Setup

func Setup(t Terminal, sys System) Plan

What the setup of a terminal changes, from what it reads; refused over SSH for every terminal but tmux, whose settings are on the other computer, and for one of macOS elsewhere

func Undo

func Undo(t Terminal, sys System) Plan

What undoing the setup of a terminal changes: what the setup added taken out, the rest as the person has it

func Unknown

func Unknown() Plan

What is said of a terminal the setup does not know

func (Plan) Done

func (p Plan) Done() bool

Whether the terminal gives the app every key it acts on already: nothing to change and nothing missing

type System

type System struct {
	// Operating system as Go names it: darwin, linux, windows
	GOOS string
	// A variable of the environment, empty when unset
	Env  func(name string) string
	Home string
	Now  time.Time
	// What a file holds, an error that is fs.ErrNotExist for one that is not there
	Read func(path string) ([]byte, error)
	// What a program says when run with the arguments, for settings no file of text holds, such as those of macOS's own programs
	Ask func(argv ...string) (string, error)
}

What the setup reads of the computer it runs on

func Here

func Here(ctx context.Context) System

This computer as the setup reads it: its system, its environment, the home folder of the person, its files, and its programs asked within a time limit; a home folder that can't be told leaves the setup only the files its variables name

type Terminal

type Terminal struct {
	ID, Name, Known string
}

A terminal the setup knows: its id, as /terminal-setup takes it, its name, and how the setup tells it is the one the app runs in

func Detect

func Detect(sys System) []Terminal

The terminals the app runs in: the one it shows in, then tmux where it runs inside tmux; none where the environment says of neither

func Find

func Find(id string) (Terminal, bool)

The terminal of the id, false for one the setup does not know

Jump to

Keyboard shortcuts

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