Last active
November 13, 2019 20:24
-
-
Save angryobject/0a6e894e168dc9471b4a53f0deed3357 to your computer and use it in GitHub Desktop.
Runs command with environment variables declared in a .env file
This file contains 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
# Runs command with environment variables declared in a .env file | |
# Usage: | |
# $ envr some fancy command to run | |
# or with a custom .env file: | |
# $ envr .my.env some fancy command to run | |
if [[ "$1" =~ ^.*\.env$ ]]; then | |
ENV_FILE=$1 | |
CMD=${@:2} | |
else | |
ENV_FILE=".env" | |
CMD=$@ | |
fi | |
env $(cat $ENV_FILE | xargs) $CMD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment