env

package
v0.0.0-...-79e800d Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 6 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 env holds the configuration file of hail, config.yaml, and the directory that holds it, as package env does in usql.

An interactive hail reads config.yaml, unless it runs under the name bash or sh, or --norc is given (D19). The file holds settings and not code. A function goes in a bash script that the file names under source, and the shell runs that script after the settings. ox reads the file, as it reads the command line, and fills Config from its keys. D27 holds the keys.

An example:

prompt: '\u@\h:\w\$ '
env:
  EDITOR: vim
set: [noclobber]
shopt: [globstar]
aliases:
  ll: ls -l
history:
  file: ~/.local/state/hail/history
  size: 10000
  control: [ignoreboth]
editor:
  vi: false
  color: true
  style: dracula
  styles:
    keyword: 'bold #ff79c6'
  bindings:
    - '"\C-o": "> output"'
    - 'set completion-ignore-case on'
source:
  - functions.sh

Index

Constants

View Source
const FileName = "config.yaml"

FileName is the name of the configuration file.

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir returns the directory of config.yaml: hail under the configuration directory of the user, from os.UserConfigDir (D19).

Types

type Config

type Config struct {
	// Prompt is PS1, and Prompt2 is PS2.
	Prompt  string `ox:"the primary prompt\\, PS1,key:prompt"`
	Prompt2 string `ox:"the secondary prompt\\, PS2,key:prompt2"`
	// Env holds the variables to set and export.
	Env map[string]string `ox:"the variables to export,key:env"`
	// Set holds the options of set -o to turn on, and Shopt the options of
	// shopt.
	Set   []string `ox:"the options of set -o to turn on,key:set"`
	Shopt []string `ox:"the options of shopt to turn on,key:shopt"`
	// Aliases holds the aliases, by name.
	Aliases map[string]string `ox:"the aliases,key:aliases"`

	// HistoryFile, HistorySize, HistoryFileSize, HistoryControl and
	// HistoryIgnore set HISTFILE, HISTSIZE, HISTFILESIZE, HISTCONTROL and
	// HISTIGNORE. A list is joined with ":".
	HistoryFile     string   `ox:"the history file\\, HISTFILE,key:history.file"`
	HistorySize     string   `ox:"the size of the history\\, HISTSIZE,key:history.size"`
	HistoryFileSize string   `ox:"the size of the history file\\, HISTFILESIZE,key:history.file_size"`
	HistoryControl  []string `ox:"HISTCONTROL,key:history.control"`
	HistoryIgnore   []string `ox:"HISTIGNORE,key:history.ignore"`

	// Vi starts the editor in vi mode, as set -o vi does. Color colors the
	// line as the user types it. Style names the style of transit that
	// gives the colors: a style that hail bundles, by its name, or a style
	// file, by its path. An empty Style is repl.DefaultStyle. Styles gives
	// the style of a kind of word, over Style.
	Vi     bool              `ox:"edit in vi mode,key:editor.vi"`
	Color  bool              `ox:"color the line,key:editor.color,default:true"`
	Style  string            `ox:"the style of the colors\\, a name or the path of a file,key:editor.style"`
	Styles map[string]string `ox:"the styles of the colors,key:editor.styles"`
	// Bindings holds the key bindings, as the lines of an inputrc file.
	// They apply after the inputrc file of the user, in order, as though
	// they were one more inputrc file (D14). A line that sets the keymap
	// holds for the lines after it.
	Bindings []string `ox:"the key bindings\\, as lines of an inputrc file,key:editor.bindings"`

	// Source holds the bash scripts that the shell runs after the settings,
	// in order. A relative path is relative to the directory of the file.
	Source []string `ox:"the scripts to run,key:source"`
}

Config is what config.yaml holds. A field that the file does not set keeps its zero value, and the shell keeps what it has.

func Load

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

Load reads the configuration file at path through ox. A file that does not exist gives the defaults and no error.

Jump to

Keyboard shortcuts

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