A common use case is sourcing local environment variables, for example with direnv, and storing them in a .envrc file. To prevent accidentally committing secrets to a repository and pushing them to origin, it’s best to encrypt local secrets. Although direnv does not support this by default, you can integrate it nicely with sops, GnuPG, and a helper function.
We need direnv and sops to encrypt files, and GnuPG to create encryption keys.
# On macOS this can be installed with Homebrew.
# On any other OS, use your package manager.
$ brew install direnv sops gnupg