On this page
Loads, validates, and caches TOML configuration for progress bar appearance, color gradients, line layout, and profile directories.
#internal/config
#internal/config
#ConfigDir
const ConfigDir = "~/.config/howmuchleft"#ConfigFile
const ConfigFile = "config.toml"#Config
type Config structConfig holds all configuration fields for howmuchleft.
#ColorEntry
type ColorEntry structColorEntry defines a gradient with optional conditions.
#LinesConfig
type LinesConfig structLinesConfig defines the content of each output line.
#ConfigPath
func ConfigPath() stringConfigPath resolves ~ to the actual home directory and returns the full path.
#DefaultLines
func DefaultLines() *LinesConfigDefaultLines returns the default line element configuration used when the user has not customized [lines] in their config.
#Default
func Default() *ConfigDefault returns a Config with all default values filled in.
#Load
func Load(path string) (*Config, error)Load reads and parses a TOML config file at path. If the file doesn't exist, returns default config (not an error). If the file has parse errors, logs a warning to stderr and returns default config.
#Get
func Get() *ConfigGet returns the cached config, loading it on first call.
#ResetCache
func ResetCache()ResetCache clears the cached config (useful for testing).
#OldConfigPath
func OldConfigPath() stringOldConfigPath returns the path to the legacy JSON config file.
#ConvertJSONToTOML
func ConvertJSONToTOML() errorConvertJSONToTOML detects an old JSON config and converts it to TOML. If old exists and new doesn't: converts, writes new, renames old to .bak. If both exist or neither exists: does nothing.
#StripJSONComments
func StripJSONComments(text string) stringStripJSONComments removes // line comments, / / block comments, and trailing commas before } or ] from JSONC text. Ported from the Node.js implementation in lib/statusline.js.