Documentation
¶
Overview ¶
Package state tracks what each loaded profile changed in the current terminal. The state lives in the __PROFILE_STATE environment variable, so it is per-terminal, inherited by subshells, and never goes stale on disk.
Index ¶
- Constants
- func AddedEntries(before, after string) []string
- func EncodeSnapshot(s *Snapshot) string
- func Environ() map[string]string
- func ListLike(before, after string) bool
- func ParseNames(lines string) (funcs, aliases []string)
- func Tracked(key string) bool
- type Entry
- type Op
- type OpKind
- type Snapshot
- type State
- type VarChange
Constants ¶
const ( // EnvState holds the encoded State of the current terminal. EnvState = "__PROFILE_STATE" // EnvSnap carries the pre-load Snapshot from __snapshot to __record. EnvSnap = "__PROFILE_SNAP" )
Variables ¶
This section is empty.
Functions ¶
func AddedEntries ¶
AddedEntries returns the list entries present in after but not in before.
func EncodeSnapshot ¶
EncodeSnapshot serializes a Snapshot for __PROFILE_SNAP.
func ListLike ¶
ListLike reports whether a change looks like entries were added to a separator-delimited list such as PATH: the before value is still inside the after one as whole entries.
func ParseNames ¶
ParseNames reads "f name" / "a name" lines as emitted by the shell hooks.
Types ¶
type Entry ¶
type Entry struct {
Name string `json:"n"`
File string `json:"f"`
Vars []VarChange `json:"v,omitempty"`
Funcs []string `json:"fn,omitempty"`
Aliases []string `json:"al,omitempty"`
Hook string `json:"h,omitempty"`
}
Entry is everything one loaded profile changed.
type Op ¶
Op is one shell operation. Value is only used by OpSetEnv.
type Snapshot ¶
type Snapshot struct {
Env map[string]string `json:"e"`
Funcs []string `json:"f,omitempty"`
Aliases []string `json:"a,omitempty"`
}
Snapshot is the environment, function and alias names of a shell at one point in time.
func DecodeSnapshot ¶
DecodeSnapshot parses a value produced by EncodeSnapshot.
type State ¶
type State struct {
Profiles []Entry `json:"p"`
}
State is the ordered stack of loaded profiles, oldest first.