.env
files such as dotenv are brilliant!
This is a very simple helper script that makes writing day-to-day bash one-liners a little more readable.
yarn global add bashenv
# Lets assume this is a .env file
NODE_ENV=debug
MY_IP_ADDRESS=127.0.0.1
SECRET_ACCESS_KEY=12345
# Echo each line to the current process
bashenv
# output:
# NODE_ENV=debug
# MY_IP_ADDRESS=127.0.0.1
# SECRET_ACCESS_KEY=12345
# script also EXPORTS each variable it finds,
# You can SOURCE the output, and those variables
# will be available to child processes
source bashenv | bash | echo $SECRET_ACCESS_KEY
# output: 12345
Convienience methods are also available:
# Add / Update a key/value pair like so.
# If no .env file is found, one is created for you
bashenv NODE_ENV production
# Read a specific key value
bashenv MY_IP_ADDRESS
# result: 127.0.0.1