ohmybuck

Export .env to shell

July 05, 2021

#!/usr/bin/env sh

## Usage
## . ./export-env.sh <some-other.env>

ENV_FILE="${1:-.env}"

unamestr=$(uname)
if [ "$unamestr" = 'Linux' ]; then
  export $(grep -v '^#' "$ENV_FILE" | xargs -d '\n')
else
  export $(grep -v '^#' "$ENV_FILE" | xargs -0)
fi

Written by Oliver Smit. I love talking about web technologies, good design practices, optimising productivity, and rapid prototyping of projects. Check out my work on Github