| Crates.io | stickyvar |
| lib.rs | stickyvar |
| version | 0.1.0 |
| created_at | 2025-09-29 05:22:40.504676+00 |
| updated_at | 2025-09-29 05:22:40.504676+00 |
| description | Create permanent-ish environment variables that you can share between sessions |
| homepage | https://github.com/ysthakur/stickyvar |
| repository | https://github.com/ysthakur/stickyvar |
| max_upload_size | |
| id | 1858977 |
| size | 39,190 |
A little utility to keep environment variables around permanently* and share them between sessions. It does this by storing them in an sqlite database.
Should support any sufficiently POSIX-y shell, as well as Nushell.
At the time of writing, this crate hasn't been published to crates.io yet, but I assume this'll work in the future:
cargo install stickyvar
Go to the latest run of the build workflow and download the zip file for your platform:
ubuntu-latest should work for Linux distroswindows-latest and macos-latest are forInside the zip file should be the executable (yes, that's the only thing inside the zip, blame GitHub for the unnecessary archiving).
git clone git@github.com:ysthakur/stickyvar.git
cargo install --path stickyvar
If you're using a sufficiently POSIX-y shell, such as Bash (get a better shell) or Zsh, then you can put the following into your .bashrc or .zshrc or whatever:
eval "$(stickyvar init sh)"
If you're using Nushell, pat yourself on the back for your great taste in shells, then put the following in env.nu:
stickyvar init sh | save --force $"($nu.cache-dir)/stickyvar.nu"
It'll create a file stickyvar.nu every time you open Nushell. Alternatively, you can also manually generate the setup script just once if you prefer.
Then, put the following in config.nu to actually load the module from the setup script:
use $"($nu.cache-dir)/stickyvar.nu" sv
The init script generated earlier should've added an sv function/module with the following subcommands:
sv set FOO BAR will set an environment variable FOO to BAR and add it to the sticky variable databasesv load FOO will grab the value of FOO from the sticky variable database, then set the environment variable FOO to that in your current shellsv load (no extra arguments) will load and set all variables from the sticky variable databasesv list will list names and values of sticky variables in the database
You can set the environment variable STICKY_VAR_DB to control which file you want variables to be stored in. The file doesn't need to exist, but the directory it's in does. You can then check that stickyvar is using the correct path using stickyvar db-path.
Here's an example:
stickyvar db-path
/home/ysthakur/.local/state/stickyvar/sticky-var.db
$env.STICKY_VAR_DB = "foo.db"
stickyvar db-path
foo.db
Suppose you have two sessions that you want to share environment variables between, but you don't want any other sessions to get the same variables. You can handle this by having both sessions use the same database file, different from the default one.
If you set the environment variable STICKY_VAR_DB to, say, ~/foo.db in both sessions, they'll both use variables from there, but other sessions will continue using the default database.
TODO asciinema recording
TODOs:
sync subcommand that reads all sticky vars and only updates env vars that are
newer than the found sticky vars$env.foo is annoying, $foo is easier