Skip to content

Instantly share code, notes, and snippets.

@christianromney
Created February 6, 2019 16:51
Show Gist options
  • Save christianromney/fe548ddaeb1fc7ee12657bc72ec586bd to your computer and use it in GitHub Desktop.
Save christianromney/fe548ddaeb1fc7ee12657bc72ec586bd to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
if [[ $1 = "dev" ]]; then
echo -e "\033[1;32mUsing dev environment"
sed -i '' -e 's/\$DB_TST/$DB_DEV/' .envrc
direnv allow
elif [[ $1 = "test" ]]; then
echo -e "\033[1;33mUsing test environment"
sed -i '' -e 's/\$DB_DEV/$DB_TST/' .envrc
direnv allow
else
if [[ -z "$DATABASE_URL" ]]; then
echo -e "\033[1;31mEnvironment not set"
else
echo "$DATABASE_URL" | grep _dev > /dev/null
if [[ $? -eq 0 ]]; then
echo -e "\033[1;32mCurrent environment: development"
else
echo -e "\033[1;33mCurrent environment: test"
fi
fi
fi
tput sgr0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment