shell

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: 0BSD Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanChildEnv added in v0.7.2

func CleanChildEnv(envList []string, fd int, pid int) []string

clean child environment to avoid duplicate multishell entries and deduplicate path

func GetFishConfigDir added in v0.4.4

func GetFishConfigDir() string

func GetFishDataDir added in v0.4.15

func GetFishDataDir() string

func GetZshConfigDir added in v0.4.4

func GetZshConfigDir() string

func Init

func Init(name string)

func ParseAliases

func ParseAliases(data string) map[string]string

func ParseFishConfig added in v0.7.0

func ParseFishConfig(dir, data string) (map[string]string, map[string]string)

func ReplaceLine added in v0.7.0

func ReplaceLine(text []byte, cursorFromEnd int) []byte

ReplaceLine builds the byte sequence that clears the shell's current input line and types text in its place. cursorFromEnd is how many characters the cursor sits to the left of the end of the line.

ctrl+u only clears the whole line from the end: it is kill-whole-line in zsh's stock emacs keymap, but kills backwards under bash (unix-line-discard), fish, zsh's vi keymap, and `bindkey '^U' backward-kill-line`. Left mid-line, everything to the right of the cursor survived and collided with the text typed next.

The cursor therefore has to reach the end first, and it walks there with the right arrow rather than ctrl+e. ctrl+e is a key people rebind -- binding it to atuin-search is common, and iris sending it opened the atuin overlay every time it rewrote the line.

func ScanPosixAliases

func ScanPosixAliases(files []string) map[string]string

func SplitAliasTokens

func SplitAliasTokens(s string) []string

Types

type AbbrScanner added in v0.7.0

type AbbrScanner interface {
	ScanAbbrs() map[string]string
}

type Adapter

type Adapter interface {
	GetName() string
	GetShellPath() string
	GetEnv(fd int, pid int) []string
	PrepareSelectSequence(selected string, cursorFromEnd int) []byte
	// ScanAliases returns a map of alias name to target command
	ScanAliases() map[string]string
}

Adapter defines the behavior for different shell environments

var Current Adapter

Current shell instance

type BashAdapter

type BashAdapter struct{}

BashAdapter implementation

func (*BashAdapter) GetEnv

func (b *BashAdapter) GetEnv(fd int, pid int) []string

func (*BashAdapter) GetName

func (b *BashAdapter) GetName() string

func (*BashAdapter) GetShellPath

func (b *BashAdapter) GetShellPath() string

func (*BashAdapter) PrepareSelectSequence

func (b *BashAdapter) PrepareSelectSequence(selected string, cursorFromEnd int) []byte

func (*BashAdapter) ScanAliases

func (b *BashAdapter) ScanAliases() map[string]string

type FishAdapter

type FishAdapter struct{}

FishAdapter implementation

func (*FishAdapter) GetEnv

func (f *FishAdapter) GetEnv(fd int, pid int) []string

func (*FishAdapter) GetName

func (f *FishAdapter) GetName() string

func (*FishAdapter) GetShellPath

func (f *FishAdapter) GetShellPath() string

func (*FishAdapter) PrepareSelectSequence

func (f *FishAdapter) PrepareSelectSequence(selected string, cursorFromEnd int) []byte

func (*FishAdapter) ScanAbbrs added in v0.7.0

func (f *FishAdapter) ScanAbbrs() map[string]string

func (*FishAdapter) ScanAliases

func (f *FishAdapter) ScanAliases() map[string]string

type ZshAdapter

type ZshAdapter struct{}

ZshAdapter implementation

func (*ZshAdapter) GetEnv

func (z *ZshAdapter) GetEnv(fd int, pid int) []string

func (*ZshAdapter) GetName

func (z *ZshAdapter) GetName() string

func (*ZshAdapter) GetShellPath

func (z *ZshAdapter) GetShellPath() string

func (*ZshAdapter) PrepareSelectSequence

func (z *ZshAdapter) PrepareSelectSequence(selected string, cursorFromEnd int) []byte

func (*ZshAdapter) ScanAliases

func (z *ZshAdapter) ScanAliases() map[string]string

Jump to

Keyboard shortcuts

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