shell

package
v0.39.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivateHermit

func ActivateHermit(w io.Writer, shell Shell, config ActivationConfig) error

ActivateHermit prints out the hermit activation script for the given shell.

func DeactivateHermit

func DeactivateHermit(w io.Writer, shell Shell, env envars.Envars) error

DeactivateHermit prints out the hermit deactivation script for the given shell.

func InstallHooks

func InstallHooks(l *ui.UI, shell Shell) error

InstallHooks for the given Shell.

func PrintHooks

func PrintHooks(shell Shell, sha256sums []string) error

PrintHooks for the given shell.

"sha256sums" is the union of all known SHA256 sums for per-environment scripts.

func Quote

func Quote(word string) string

Quote returns a word quoted with single-quotes for consumption by shells.

This is necessary because kballard/go-shellquote does not quote leading "=T", which in zsh is for some unfathomable reason equivalent to $(which t) and breaks :( http://zsh.sourceforge.net/Doc/Release/Expansion.html#g_t_0060_003d_0027-expansion

Copied from MIT licensed: https://github.com/kballard/go-shellquote/blob/95032a82bc518f77982ea72343cc1ade730072f0/quote.go#L70

Types

type ActivationConfig added in v0.2.2

type ActivationConfig struct {
	Root   string
	Prompt string
	Env    envars.Envars
}

ActivationConfig for shells.

type Bash

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

Bash represent the Bash shell

func (*Bash) ActivationHooksCode

func (sh *Bash) ActivationHooksCode() (script string, err error)

func (*Bash) ActivationHooksInstallation

func (sh *Bash) ActivationHooksInstallation() (path, script string, err error)

func (*Bash) ActivationScript

func (sh *Bash) ActivationScript(w io.Writer, config ActivationConfig) error

func (*Bash) ApplyEnvars

func (sh *Bash) ApplyEnvars(w io.Writer, env envars.Envars) error

func (*Bash) DeactivationScript

func (sh *Bash) DeactivationScript(w io.Writer) error

func (*Bash) Name

func (sh *Bash) Name() string

type Changes

type Changes struct {
	Env    envars.Envars
	Add    envars.Ops
	Remove envars.Ops
}

Changes encapsulates changes that need to be applied to the active environment after a change

func NewChanges

func NewChanges(env envars.Envars) *Changes

NewChanges returns a new empty change set

func (Changes) Merge

func (c Changes) Merge(o *Changes) *Changes

Merge combines two change sets into one

type Shell

type Shell interface {
	Name() string
	// ActivationHooksInstallation returns the path and shell fragment for injecting activation code to the shell initialisation.
	ActivationHooksInstallation() (path, script string, err error)
	// ActivationHooksCode returns the shell fragment for activation/deactivation hooks
	ActivationHooksCode() (script string, err error)
	// ActivationScript for this shell.
	ActivationScript(w io.Writer, config ActivationConfig) error
	// ApplyEnvars writes the shell fragment required to apply the given envars.
	//
	// Envars with empty values should be deleted.
	ApplyEnvars(w io.Writer, env envars.Envars) error
	// DeactivationScript for this shell.
	DeactivationScript(w io.Writer) error
}

Shell abstracts shell specific functionality

func Detect

func Detect() (Shell, error)

Detect the user's shell.

func Resolve added in v0.37.0

func Resolve(name string) (Shell, error)

type Zsh

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

Zsh represents the Zsh shell

func (*Zsh) ActivationHooksCode

func (sh *Zsh) ActivationHooksCode() (script string, err error)

func (*Zsh) ActivationHooksInstallation

func (sh *Zsh) ActivationHooksInstallation() (path, script string, err error)

func (*Zsh) ActivationScript

func (sh *Zsh) ActivationScript(w io.Writer, config ActivationConfig) error

func (*Zsh) ApplyEnvars

func (sh *Zsh) ApplyEnvars(w io.Writer, env envars.Envars) error

func (*Zsh) DeactivationScript

func (sh *Zsh) DeactivationScript(w io.Writer) error

func (*Zsh) Name

func (sh *Zsh) Name() string

Jump to

Keyboard shortcuts

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