shell

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACK           = 6
	TAB           = 9
	LF            = 10
	CR            = 13
	US            = 31
	SPACE         = 32
	AMPERSTAND    = 38
	SINGLE_QUOTE  = 39
	PLUS          = 43
	NINE          = 57
	QUESTION      = 63
	UPPERCASE_Z   = 90
	OPEN_BRACKET  = 91
	BACKSLASH     = 92
	UNDERSCORE    = 95
	CLOSE_BRACKET = 93
	BACKTICK      = 96
	LOWERCASE_Z   = 122
	TILDA         = 126
	DEL           = 127
)

Variables

This section is empty.

Functions

func BashEscape

func BashEscape(str string) string

https://github.com/solidsnack/shell-escape/blob/master/Text/ShellEscape/Bash.hs

A Bash escaped string. The strings are wrapped in @$\'...\'@ if any bytes within them must be escaped; otherwise, they are left as is. Newlines and other control characters are represented as ANSI escape sequences. High bytes are represented as hex codes. Thus Bash escaped strings will always fit on one line and never contain non-ASCII bytes.

Types

type Export

type Export map[string]*string

Export represents environment variables to add and remove on the host shell.

func (Export) Add

func (e Export) Add(key, value string)

Add represents the addition of a new environment variable

func (Export) Remove

func (e Export) Remove(key string)

Remove represents the removal of a given `key` environment variable.

type Shell

type Shell interface {
	// Hook is the string that gets evaluated into the host shell config and
	// setups direnv as a prompt hook.
	Hook() string

	// Export outputs the a string that exports the given environment variables
	Export(key, value string) string

	// ExportAll outputs a string that exports all the given environment
	ExportAll(Export) string

	// Unset unsets the given key from the host shell
	Unset(key string) string

	// Shell returns the name of the shell
	Shell() string

	// RCFile returns the path to the RC file
	RCFile() string
}

Shell is the interface that represents the interaction with the host shell.

var Bash Shell = bash{}

Bash shell instance

var Fish Shell = fish{}

Fish adds support for the fish shell as a host

var Zsh Shell = zsh{}

Zsh adds support for the venerable Z shell.

func Detect

func Detect(target string) Shell

DetectShell returns a Shell instance from the given target.

target is usually $0 and can also be prefixed by `-`

Jump to

Keyboard shortcuts

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