Created
April 9, 2020 11:27
-
-
Save Sebi2020/f271a2846844bedc158181df936314e7 to your computer and use it in GitHub Desktop.
Allows you to run programs with an environment specified by `.env` files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -lt 1 ]; then | |
echo "Missing parameter!" | |
exit 1 | |
fi | |
env $(cat .env | xargs) $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Save the file in your home directory. For example as
~/.runwithenv.sh
and make it executable (chmod u+x ~/.runwithenv.sh
). Finally add the following alias at the end of your~/.bashrc
:The script expects the
.env
file to be in the same path as your executable.The
.env
file should have the following format:and so on. Now you're able to execute scripts with the environment specified by invoking any executable like this: