shellutil

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShellType_bash    = "bash"
	ShellType_zsh     = "zsh"
	ShellType_fish    = "fish"
	ShellType_pwsh    = "pwsh"
	ShellType_unknown = "unknown"
)
View Source
const (
	// there must be no spaces in these integration dir paths
	ZshIntegrationDir  = "shell/zsh"
	BashIntegrationDir = "shell/bash"
	PwshIntegrationDir = "shell/pwsh"
	FishIntegrationDir = "shell/fish"
	WaveHomeBinDir     = "bin"
	ZshHistoryFileName = ".zsh_history"
)
View Source
const DefaultShellPath = "/bin/bash"
View Source
const DefaultTermCols = 80
View Source
const DefaultTermRows = 24
View Source
const DefaultTermType = "xterm-256color"
View Source
const (
	MaxQuoteSize = 10000000 // 10MB
)

Variables

View Source
var (
	//go:embed shellintegration/zsh_zprofile.sh
	ZshStartup_Zprofile string

	//go:embed shellintegration/zsh_zshrc.sh
	ZshStartup_Zshrc string

	//go:embed shellintegration/zsh_zlogin.sh
	ZshStartup_Zlogin string

	//go:embed shellintegration/zsh_zshenv.sh
	ZshStartup_Zshenv string

	//go:embed shellintegration/bash_bashrc.sh
	BashStartup_Bashrc string

	//go:embed shellintegration/bash_preexec.sh
	BashStartup_Preexec string

	//go:embed shellintegration/fish_wavefish.sh
	FishStartup_Wavefish string

	//go:embed shellintegration/pwsh_wavepwsh.sh
	PwshStartup_wavepwsh string

	ZshExtendedHistoryPattern = regexp.MustCompile(`^: [0-9]+:`)
)

Functions

func AddTokenSwapEntry

func AddTokenSwapEntry(entry *TokenSwapEntry) error

func DefaultTermSize

func DefaultTermSize() waveobj.TermSize

func DetectLocalShellPath

func DetectLocalShellPath() string

func DetectShellTypeAndVersion

func DetectShellTypeAndVersion() (string, string, error)

func DetectShellTypeAndVersionFromPath

func DetectShellTypeAndVersionFromPath(shellPath string) (string, string, error)

func EncodeEnvVarsForShell

func EncodeEnvVarsForShell(shellType string, env map[string]string) (string, error)

func FindGitBash

func FindGitBash(config *wconfig.FullConfigType, rescan bool) string

func FixupWaveZshHistory

func FixupWaveZshHistory() error

func FormatOSC

func FormatOSC(oscNum int, parts ...string) string

func GetEnvStrKey

func GetEnvStrKey(envStr string) string

func GetLocalBashRcFileOverride

func GetLocalBashRcFileOverride() string

func GetLocalWaveFishFilePath

func GetLocalWaveFishFilePath() string

func GetLocalWavePowershellEnv

func GetLocalWavePowershellEnv() string

func GetLocalWshBinaryPath

func GetLocalWshBinaryPath(version string, goos string, goarch string) (string, error)

func GetLocalZshZDotDir

func GetLocalZshZDotDir() string

func GetMacUserShell

func GetMacUserShell() string

func GetShellTypeFromShellPath

func GetShellTypeFromShellPath(shellPath string) string

func GetTerminalResetSeq

func GetTerminalResetSeq() string

func HardQuote

func HardQuote(s string) string

func HardQuoteFish

func HardQuoteFish(s string) string

does not encode newlines or backticks

func HardQuotePowerShell

func HardQuotePowerShell(s string) string

func HasWaveZshHistory

func HasWaveZshHistory() (bool, int64)

func InitCustomShellStartupFiles

func InitCustomShellStartupFiles() error

in a Once block so it can be called multiple times we run it at startup, but also before launching local shells so we know everything is initialized before starting the shell

func InitRcFiles

func InitRcFiles(waveHome string, absWshBinDir string) error

absWshBinDir must be an absolute, expanded path (no ~ or $HOME, etc.) it will be hard-quoted appropriately for the shell

func IsExtendedZshHistoryFile

func IsExtendedZshHistoryFile(fileName string) (bool, error)

func IsValidEnvVarName

func IsValidEnvVarName(name string) bool

func SoftQuote

func SoftQuote(s string) string

func UpdateCmdEnv

func UpdateCmdEnv(cmd *exec.Cmd, envVars map[string]string)

func WaveshellLocalEnvVars

func WaveshellLocalEnvVars(termType string) map[string]string

Types

type TokenSwapEntry

type TokenSwapEntry struct {
	Token      string             `json:"token"`
	RpcContext *wshrpc.RpcContext `json:"rpccontext,omitempty"`
	Env        map[string]string  `json:"env,omitempty"`
	ScriptText string             `json:"scripttext,omitempty"`
	Exp        time.Time          `json:"-"`
}

func GetAndRemoveTokenSwapEntry

func GetAndRemoveTokenSwapEntry(token string) *TokenSwapEntry

func (*TokenSwapEntry) PackForClient

func (t *TokenSwapEntry) PackForClient() (string, error)

type UnpackedTokenType

type UnpackedTokenType struct {
	Token      string             `json:"token"` // uuid
	RpcContext *wshrpc.RpcContext `json:"rpccontext,omitempty"`
}

func UnpackSwapToken

func UnpackSwapToken(token string) (*UnpackedTokenType, error)

func (*UnpackedTokenType) Pack

func (t *UnpackedTokenType) Pack() (string, error)

Jump to

Keyboard shortcuts

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