conf

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 6 Imported by: 0 modules, 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 conf reads sitrep's settings: the environment first, then sitrep.conf in the state folder. The file is read, never run, so it holds NAME=value lines only (single quotes, double quotes, backslashes and $'...' are understood, so what printf %q wrote reads back; comments, export, variables and commands are not). The bash status line used to source the file, which let it override the environment and run code; that is gone.

Index

Constants

View Source
const (
	DefaultQueueItems       = 5
	DefaultHighlightSeconds = 60
	DefaultHighlightSGR     = "48;5;238"
)

Defaults of the settings that have one.

Variables

View Source
var ErrMultiline = errors.New("the command has more than one line")

ErrMultiline says a command cannot be kept in sitrep.conf, which holds one setting per line.

Functions

func Quote

func Quote(s string) string

Quote writes s as one shell word that Unquote reads back: in single quotes, a single quote written as '\”.

func Unquote

func Unquote(s string) string

Unquote reads one shell word the way sitrep.conf holds it, without running anything: single quotes, double quotes and backslash escapes and $'...' are understood, and variables and commands are left as they are.

Types

type Conf

type Conf struct {
	File   string              // path of sitrep.conf
	Getenv func(string) string // the environment; os.Getenv when nil
}

Conf looks settings up.

func Open

func Open(stateDir string) Conf

Open names the conf file in a state folder.

func (Conf) DropHUD

func (c Conf) DropHUD() error

DropHUD removes our SITREP_HUD_CMD line. Every other line is the user's and stays; the file goes when nothing else is left.

func (Conf) FromFile

func (c Conf) FromFile(name string) string

FromFile is a setting as the file holds it, whatever the environment says: setup and its removal save and restore what is in the file.

func (Conf) Get

func (c Conf) Get(name string) string

Get returns a setting: the environment wins, then the first NAME=value line of the file. It is empty when unset.

func (Conf) HighlightSGR

func (c Conf) HighlightSGR() string

HighlightSGR is the terminal style of the highlight. Only digits and semicolons are accepted, because the value reaches the terminal.

func (Conf) HighlightSeconds

func (c Conf) HighlightSeconds() int

HighlightSeconds is how long a session counts as recently active (SITREP_HIGHLIGHT_SECONDS); 0 turns the highlight off.

func (Conf) PutHUD

func (c Conf) PutHUD(cmd string) error

PutHUD saves the upstream status line, replacing any earlier one and keeping the user's own lines.

func (Conf) QueueItems

func (c Conf) QueueItems() int

QueueItems is how many queue items a listing shows (SITREP_QUEUE_ITEMS).

Jump to

Keyboard shortcuts

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