bath is a terminal UI (TUI) tool for managing environment-variable profiles (e.g. PATH, compiler flags, and linker flags) backed by SQLite.
Features
- Profiles in SQLite: store multiple named profiles and switch/export them consistently
- Profiles as text: edit a profile like a
.envfile; list vars take one value per indented line - Export for shell eval: print
export ...statements for the selected profile - Modes: prepend/append/replace behavior per variable
- Known-var catalog: ~220 env vars plus ~30 name patterns from AWS, Postgres, MySQL, Docker, Kubernetes, Go, Rust, Python, Node, Java, Terraform, GCP, Azure, Git and more, with their kind and separator filled in; extend it with your own
- Highlighting and checks: names, values, separators and
exportlines are colored with the active theme; errors are marked per line and block saving - Crash-safe terminal: raw mode and the alternate screen are always restored, even on errors or panics
Installation
Usage
- TUI mode:
-
Tabs:
1 <profile>.env·2 profiles·3 library·4 defs·5 export·6 help -
Everywhere
Tab/Shift+Tab: next / previous tab (Tabaccepts an open completion first)Alt+1…Alt+6: jump to a tabCtrl+P: commands (also:outside the text tabs)Ctrl+S: save the current tabCtrl+Q/Ctrl+C: quit; asks first when a tab has unsaved changes (marked●)
-
The env tab edits the active profile as text:
PATH = /opt/llvm/bin
$HOME/bin
PGHOST = localhost
ACME [list ','] = a,b
-
One var per line; indented lines add parts to a list var. Values are split on the var's separator, so pasting
/a:/bworks too. -
Typing a name suggests builtin, your own and catalog vars;
TabinsertsNAME =. Catalog vars keep their kind and separator. -
[list ',']or[value]after a new name sets its kind; it is saved as a def and removed from the text. -
Entercontinues a list at the value column;Enteron an empty indented line ends the list. -
Esc Escdiscards unsaved changes,Ctrl+Zundoes,Ctrl+K/Ctrl+Ddelete / duplicate a line,Alt+↑/Alt+↓move it,Ctrl+Linserts a library value. -
Saving with errors does not write anything and jumps to the first bad line.
-
Profiles tab:
Enteruse,aadd,erename,yduplicate (name prefilled as<name>-copy),ddelete,/filter. Blank and taken names are rejected, and the last profile is kept. -
Library tab: values you reuse, one per line, with optional tags (
/opt/llvm/bin # llvm, clang). The side pane lists the profiles that use the value on the cursor line. -
Defs tab: your variable definitions,
NAME list ','orNAME value. Deleting a def that a profile still uses is refused. The side pane lists the catalog (Ctrl+Ffilters it). -
Export tab: the shell output for the active profile;
mcycles prepend/append/replace,ycopies it to the clipboard (OSC 52), and unsaved env changes appear as a diff. -
Commands (
Ctrl+P; aliases separated by/)add-var/new-var/av,add-item/new-item/ai,add-def/new-def/ad,add-profile/new-profile/aprm/del[VAR]: remove a var from the env file, or the line/profile under the cursoruse/switch <profile>,dup,rename,save/w,theme <name>,q/quit/exitenv,profiles,library/lib/items,defs,export,help
-
Theming
- Config file:
~/.config/bath/config.toml(or$XDG_CONFIG_HOME/bath/config.toml) - Example:
- Config file:
[]
= "dracula"
# Optional overrides (accepts oklch(...) like DaisyUI, or #RRGGBB)
= "oklch(75% 0.18 346)"
= "#0b0f19"
- Your own known vars
- File:
~/.config/bath/catalog.toml(or$XDG_CONFIG_HOME/bath/catalog.toml) - Entries with the same
nameorpatternas a built-in one replace it; your patterns are tried before the built-in ones. Exact names always win over patterns. If the file cannot be parsed, bath starts with the built-in catalog and shows the error in the status line. - Example:
- File:
[[]]
= "ACME_API_TOKEN"
= "scalar"
= "acme"
[[]]
= "ACME_*_HOSTS" # `*` matches any characters
= "list"
= "," # lists default to ":"
= "acme"
- Demo
The README includes a GIF (assets/bath.gif) showing the TUI in action.
- Export a profile:
- Eval in your shell:
- Choose export mode (
prependis default):
- Export help:
Data storage
Bath stores profiles in a SQLite database at:
~/.bath.db
Development
pre-commit hooks
This repository includes a .pre-commit-config.yaml to run basic checks locally (formatting, clippy, tests).
CI
GitHub Actions runs the following on every push and pull request:
cargo fmt --checkcargo clippy -- -D warningscargo test
Releasing (crates.io)
Releases are automated with release-plz (it opens a release PR and publishes to crates.io after merge).
- Required GitHub setting: in
Settings → Actions → General, set workflow permissions to allow GitHub Actions to create and approve pull requests. See the official quickstart: https://release-plz.dev/docs/github/quickstart - Required secret:
CARGO_REGISTRY_TOKEN(crates.io token with scopespublish-newandpublish-update), used by.github/workflows/release-plz.yml.
License
GPL-3.0. See LICENSE.