path-rc home

Logical project partitioning and more

Your shell, set up for the directory you're in.

pathrc sets environment variables, aliases and PATH entries as you cd into a project, and takes them away again when you leave. Secrets stay encrypted with age until the moment they're needed.

bash · zsh · fish · Linux and macOS

A terminal: prod's .pathrc.toml holds an encrypted value; cd prod decrypts it in memory and sets AWS_ACCOUNT_ID=111111111111 and AWS_REGION=eu-west-1; echo prints the account; cd .. unsets AWS_ACCOUNT_ID and restores AWS_REGION=eu-west-2.

How it works

One file per directory

A .pathrc.toml holds settings, not scripts: env, alias and path.prepend, in a [common] table for every shell and [bash], [zsh] and [fish] tables of their own.

Inherited down the tree

Files apply from the outermost directory in. A sub-directory overrides just what differs, such as one AWS account in a project of many, and unset removes what it shouldn't have.

Encrypted with age

Values in a [common.enc] table are decrypted in memory with your age or SSH key, never written to disk. pathrc secret adds one without echo; pathrc edit shows them decrypted and encrypts what you change for your team.

Undone when you leave

Leave a directory and its variables are unset, overridden values come back, and your own settings are restored. Nothing from project A leaks into project B.

Nothing runs until allowed

A cloned repository can't change your shell: each file applies only after pathrc allow, and again after every change to it.

Fast on every cd

Moving around inside a project reads nothing and decrypts nothing; pathrc only works when the files in scope change.

Secrets stay secret until you need them

Put credentials in the .enc tables of the project's .pathrc.toml and commit it. Each value is encrypted with age for everyone listed in the nearest .pathrc-recipients, using their age or SSH public keys, while the names stay readable, so a review shows which secret changed.

When you cd in, pathrc decrypts them in memory with your own key and sets the variables. The plaintext never touches the disk, and leaving the directory unsets them again. A var is kept from the programs you start altogether.

A terminal window: an encrypted value above an arrow, and below it the environment variable it becomes

An AWS project with an account per directory

aws-project/.pathrc.toml

[common]
env.AWS_REGION = "eu-west-2"
env.TF_VAR_project = "billing"
path.prepend = ["bin"]
alias.tfp = "terraform plan"

aws-project/prod/.pathrc.toml 1 encrypted value

[common]
env.AWS_REGION = "eu-west-1"  # only prod differs
unset.env = ["AWS_PROFILE"]

[common.enc]
env.AWS_ACCOUNT_ID = "YWdlLWVuY3J5cHRpb24ub3Jn…"

Install

The latest release for Linux (x86-64, arm64) or macOS (Intel, Apple Silicon), checked against its SHA-256 checksum and installed to /usr/local/bin:

curl -fsSL https://path-rc.com/install.sh | sh

A particular version, or somewhere you can write without sudo:

curl -fsSL https://path-rc.com/install.sh | PATHRC_VERSION=v0.3.0 sh
curl -fsSL https://path-rc.com/install.sh | PATHRC_INSTALL_DIR=$HOME/.local/bin sh

Then hook it into your shell's rc file:

eval "$(pathrc init)"             # ~/.bashrc or ~/.zshrc
pathrc init fish | source         # ~/.config/fish/config.fish

And make a first file:

cd ~/work/aws-project
pathrc edit              # create .pathrc.toml in $EDITOR; saving allows it
pathrc secret AWS_ACCOUNT_ID   # add a secret, typed without echo
pathrc list              # the files in scope, and any problems

Other platforms can build from source with cargo install --git https://github.com/path-rc/pathrc. On Windows, use WSL. Every release is on GitHub.