config

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseSize

func ParseSize(value string) (int64, error)

ParseSize parses a human-friendly size string (e.g. "1MB", "512KB"). Returns -1 for unlimited values like "unlimited".

Types

type AgentConfig

type AgentConfig struct {
	Default   string   `toml:"default"`
	Timeout   string   `toml:"timeout"`
	Transport string   `toml:"transport"` // "stdio" or "http"
	Command   string   `toml:"command"`   // For stdio transport
	Args      []string `toml:"args"`      // For stdio transport
	URL       string   `toml:"url"`       // For http transport (e.g., "http://localhost:11434/api/generate")
	Model     string   `toml:"model"`     // For http transport (e.g., "codellama")
}

type ClipboardConfig

type ClipboardConfig struct {
	MaxOutputSize  string `toml:"max_output_size"`
	BufferSize     int    `toml:"buffer_size"`
	PreserveColors bool   `toml:"preserve_colors"`
}

func (*ClipboardConfig) ParseMaxOutputSize

func (c *ClipboardConfig) ParseMaxOutputSize() (int64, error)

ParseMaxOutputSize parses the MaxOutputSize string and returns bytes.

type CompletionsConfig

type CompletionsConfig struct {
	Fuzzy            bool `toml:"fuzzy"`
	FileIcons        bool `toml:"file_icons"`
	CobraEnabled     bool `toml:"cobra_enabled"`
	MaskSensitiveEnv bool `toml:"mask_sensitive_env"` // Mask values of sensitive env vars (KEY, SECRET, TOKEN, etc.)
}

type Config

type Config struct {
	Shell       ShellConfig       `toml:"shell"`
	Input       InputConfig       `toml:"input"`
	Prompt      PromptConfig      `toml:"prompt"`
	Agent       AgentConfig       `toml:"agent"`
	History     HistoryConfig     `toml:"history"`
	Completions CompletionsConfig `toml:"completions"`
	Clipboard   ClipboardConfig   `toml:"clipboard"`
	Prediction  PredictionConfig  `toml:"prediction"`
}

Config represents the Hash shell configuration.

func Default

func Default() *Config

Default returns a Config with default values.

func Load

func Load(configDir string) (*Config, error)

Load reads configuration from the given config directory. Falls back to defaults for missing values. On parse errors, returns defaults with error (shell should warn but continue).

func LoadWithWarnings added in v0.4.3

func LoadWithWarnings(configDir string, warn io.Writer) *Config

LoadWithWarnings is like Load but writes warnings to the given writer. This is the preferred way to load config as it handles errors gracefully.

type HistoryConfig

type HistoryConfig struct {
	Enabled    bool   `toml:"enabled"`
	Path       string `toml:"path"`
	MaxEntries string `toml:"max_entries"`
	MaxAge     string `toml:"max_age"`
}

type InputConfig

type InputConfig struct {
	Keybindings  string `toml:"keybindings"`    // "helix", "emacs", "vim"
	Gutter       bool   `toml:"gutter"`         // Show visual indicator for multiline
	MaxPasteSize string `toml:"max_paste_size"` // Maximum paste size (e.g., "10MB")
}

InputConfig configures the input/editing mode.

func (*InputConfig) ParseMaxPasteSize added in v0.4.3

func (c *InputConfig) ParseMaxPasteSize() uint

ParseMaxPasteSize parses the MaxPasteSize string and returns bytes. Returns default of 10MB if not set or invalid.

type PredictionConfig

type PredictionConfig struct {
	Enabled             bool     `toml:"enabled"`
	AcceptKeys          []string `toml:"accept_keys"`
	ConfidenceThreshold float64  `toml:"confidence_threshold"`
	PathMinCount        int      `toml:"path_min_count"`
	PathRecencyHours    int      `toml:"path_recency_boost_hours"`
}

PredictionConfig configures command and path prediction.

type PromptConfig

type PromptConfig struct {
	Mode         string `toml:"mode"`
	StarshipPath string `toml:"starship_path"`
	Alignment    string `toml:"alignment"` // "left" or "right"
}

type ShellConfig

type ShellConfig struct {
	Editor          string             `toml:"editor"`
	Keybindings     string             `toml:"keybindings"`
	InitCommands    []string           `toml:"init_commands"`    // Legacy: run always
	ProfileCommands []string           `toml:"profile"`          // Run on login shells
	RCCommands      []string           `toml:"rc_commands"`      // Run on interactive shells
	DisableBuiltins []string           `toml:"disable_builtins"` // e.g., ["cd"] to use zoxide
	StartupFiles    StartupFilesConfig `toml:"startup_files"`
}

type StartupFilesConfig

type StartupFilesConfig struct {
	Login       []string `toml:"login"`       // Files to source for login shells
	Interactive []string `toml:"interactive"` // Files to source for interactive shells
}

StartupFilesConfig specifies which files to source at startup.

Jump to

Keyboard shortcuts

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