spirited-env loads environment variables based on the directory you are currently in, while storing env files in a central location.
go install github.com/0robustus1/spirited-env/cmd/spirited-env@latest- Project paths are canonicalized (
Abs + Clean + EvalSymlinks). - Canonical path
/Users/tim/work/appmaps to:~/.config/spirited-env/environs/Users/tim/work/app/.env
- Default behavior is layered merge (parent directories first, current directory overrides).
Config path precedence:
SPIRITED_ENV_CONFIG_HOMEXDG_CONFIG_HOME/spirited-env~/.config/spirited-env
Environs storage precedence:
SPIRITED_ENV_HOME<config-base>/environs
Backup storage path:
<config-base>/backups/<canonical-source-file-path>
spirited-env reads optional configuration from <config-base>/config.yaml.
merge_strategy: layered
directory_mode: "0700"
file_mode: "0600"
restore_original_values: true
report_env_changes: true
migration_suggestion_mode: offOptions:
merge_strategy:layered(default) ornearest.directory_mode: octal permission string for created mapping directories.file_mode: octal permission string for created/enforced.envfiles.restore_original_values:true(default) restores pre-existing shell values when a key stops being managed.report_env_changes:true(default) reports loaded/unloaded variable names on directory-triggered interactive loads.migration_suggestion_mode: controls interactive migration hints for.envrcfiles. Values:off(default),if_unmapped,always.
When config.yaml is missing, defaults are used (layered, 0700, 0600, restore_original_values: true, report_env_changes: true, migration_suggestion_mode: off).
Change reports are emitted only for interactive shell hooks and are written to stderr, so shell-eval output on stdout remains clean for scripting.
Migration suggestions are also interactive-only and written to stderr.
To print the effective configuration as valid YAML (useful as a bootstrap file):
spirited-env config showspirited-env path [dir]
spirited-env edit [dir]
spirited-env load [dir] --shell bash|zsh|fish
spirited-env refresh [dir] [--shell bash|zsh|fish]
spirited-env no-env-exec <command> [args...]
spirited-env status [dir]
spirited-env move <old-dir> <new-dir> [--force]
spirited-env import [dir] [--from <path>] [--replace]
spirited-env migrate [dir] [--from <path>] [--replace]
spirited-env config show
spirited-env state show
spirited-env state reset --shell bash|zsh|fish
spirited-env init bash|zsh|fish
spirited-env completion fish
spirited-env completion install fish
spirited-env doctor
spirited-env versionrefresh mirrors load behavior and auto-detects the active shell from process parentage when --shell is omitted.
no-env-exec executes a command after removing spirited-env managed overlays from the child process environment (restoring original values when known).
You can import or migrate .envrc files into the centralized spirited-env mapping.
spirited-env import .
spirited-env migrate .
spirited-env import . --from ./custom.envrc --replaceBehavior:
import: reads source assignments and writes them into the mapped.envfile.migrate: performs import, then moves the source file into centralized backups.- supported source lines:
KEY=VALUEandexport KEY=VALUE(plus comments/blank lines). - unsupported shell syntax fails hard, reports all invalid lines, and writes nothing.
Print the snippet and append it to your shell config manually.
spirited-env init bash
spirited-env init zsh
spirited-env init fishFor fish, both of the following are supported:
spirited-env init fish | source
eval (spirited-env init fish)spirited-env init fish | source is the preferred form.
Generate completion script:
spirited-env completion fishInstall completion script into fish's user completion path:
spirited-env completion install fishManual install (equivalent):
mkdir -p ~/.config/fish/completions
spirited-env completion fish > ~/.config/fish/completions/spirited-env.fishTo activate immediately in the current shell:
source ~/.config/fish/completions/spirited-env.fishSupported dotenv subset:
KEY=VALUEexport KEY=VALUE- comments and blank lines
- single and double quoted values
spirited-env does not execute shell code from env files.