shell

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HookUpdateMessage

func HookUpdateMessage(configDir, rcFile, currentVersion string, credHelperInstalled ...bool) string

HookUpdateMessage returns a one-line hint shown in the terminal on shell open when gitswitch needs attention. Returns "" when everything is current.

Checks (in priority order):

  1. No version file + shell marker present → old install, nudge to reinstall
  2. Shell hook content changed + something else needed → combined message
  3. Shell hook content changed only → plain "shell updated" message
  4. HTTPS and/or Session Isolation needed, hook otherwise current → targeted nudge

credHelperInstalled should be the result of git.IsCredentialHelperInstalled(). Passing it as a variadic bool avoids an import cycle (shell ← git). Dev/empty versions are ignored so local builds don't corrupt the version file.

func Install

func Install(sh Shell, fw Framework, alias string) (string, error)

Install writes the appropriate integration for the detected framework. alias is the short command alias to add (e.g. "gs"); pass "" to skip the alias line. Returns a human-readable description of what was done.

func InstallGHWrapper added in v0.3.0

func InstallGHWrapper(sh Shell) (string, error)

InstallGHWrapper writes the `gh` wrapper function to sh's rc file. It is independent of the main shell-integration block (marker) so it can be toggled without touching the nudge/prompt/completion setup.

func InstalledHookIsCurrent

func InstalledHookIsCurrent(rcFile string) bool

InstalledHookIsCurrent returns true when the installed hook already contains "gitswitch hook-check", the fingerprint added alongside hook-version tracking. Its presence means the hook is already the current format and no reinstall is needed.

func IsGHWrapperInstalled added in v0.3.0

func IsGHWrapperInstalled(path string) bool

IsGHWrapperInstalled checks whether the gh wrapper block exists in path.

func IsInstalled

func IsInstalled(path string) bool

IsInstalled checks whether the gitswitch marker exists in the given file.

func RCFile

func RCFile(sh Shell) string

RCFile returns the shell rc file path for the given shell.

func Reinstall

func Reinstall(sh Shell, fw Framework, alias string) (string, error)

Reinstall removes the existing integration block and writes a fresh one. Use this to apply alias changes without requiring a manual uninstall/install cycle.

func Uninstall

func Uninstall(sh Shell) (string, error)

Uninstall removes the gitswitch marker block from the rc file for the provided shell, removes it from starship.toml if present, and removes the OMZ plugin file if present. Returns a human-readable description of what was removed.

func UninstallGHWrapper added in v0.3.0

func UninstallGHWrapper(sh Shell) (string, error)

UninstallGHWrapper removes the `gh` wrapper block from sh's rc file.

func WriteHookVersion

func WriteHookVersion(configDir, version string) error

WriteHookVersion persists the installed hook version+revision to configDir/hook-version, as "version|revision". Skips writing when version is "dev" so local/test builds don't corrupt the version file and cause spurious "dev → vX.Y.Z" nudges for real installs.

Types

type Framework

type Framework int
const (
	FrameworkRaw Framework = iota
	FrameworkOMZ
	FrameworkP10k
	FrameworkStarship
)

func DetectFramework

func DetectFramework() Framework

DetectFramework inspects environment variables to identify the prompt framework.

type Shell

type Shell int
const (
	ShellUnknown Shell = iota
	ShellZsh
	ShellBash
	ShellFish
)

func DetectShell

func DetectShell() Shell

DetectShell infers the current shell from $SHELL.

Jump to

Keyboard shortcuts

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