shell

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 4 Imported by: 1 module, 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

Package shell composes the completion scripts git-stack installs: cobra's generated script for the git-stack binary plus the hooks that make `git stack <TAB>` and git aliases such as `git co <TAB>` complete through the same engine.

Index

Constants

This section is empty.

Variables

View Source
var All = []Shell{Bash, Zsh, Fish}

All lists the supported shells.

Functions

func Arg added in v0.2.0

func Arg(s string) (quoted string, ok bool)

Arg makes s safe to paste as one argument into bash, zsh or fish: as it is when nothing in it is special, otherwise in single quotes ('\” for a quote, which all three read the same way). ok is false when s holds a control character: no quoting makes that safe to paste (a newline ends the command, a pasted tab can trigger completion), so callers should describe what to do rather than print a command.

func Compose

func Compose(sh Shell, cobraScript string) (string, error)

Compose returns the script to install for sh, given cobra's generated script for the git-stack binary.

func Path added in v0.2.0

func Path(p string) (string, bool)

Path is Arg for a path, leaving a leading ~/ outside the quotes so the shell still expands it (~/'my app' works in all three).

Types

type Env

type Env struct {
	Home          string
	XDGConfigHome string
	XDGDataHome   string
}

Env is the subset of the environment path resolution needs.

func (Env) Hint

func (e Env) Hint(sh Shell) string

Hint explains anything the user must do by hand after installing.

func (Env) InstallPath

func (e Env) InstallPath(sh Shell) string

InstallPath is where the composed script lives for sh.

type Shell

type Shell string

Shell is a supported shell.

const (
	Bash Shell = "bash"
	Zsh  Shell = "zsh"
	Fish Shell = "fish"
)

func Detect

func Detect(shellEnv string) (Shell, bool)

Detect guesses the login shell from $SHELL.

func Parse

func Parse(name string) (Shell, error)

Parse validates a shell name.

Jump to

Keyboard shortcuts

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