Source env vars from a file encrypted with ccrypt.
Only works on linux, as far as I can tell.
Write your environment variables into a .env file as normal:
export EXAMPLE=testEncrypt the file with ccrypt:
cccrypt example.envwhen you want to load the variables into your current shell, run
. csource example.env.cptThe environment variables you have configured are now loaded into your shell, but the file is still encrypted.
The example here has a decryption key of test
I often use environment variables to store secrets. But I do not want to leave these secrets un encrypted on disk.
csource is an extremely simple way to keep the file of environment variables encrypted, while making it fairly easy to use them in development work.
You can make it easy to run csource by adding it to your $PATH or creating a symbolic link to it in $HOME/.local/bin.
The whole thing is:
source <(ccat $1)
I bet there are much better ways to do this. If you come across this project and know of something better, let me know!
Also we're sourcing twice - is that necessary?