Skip to content

Instantly share code, notes, and snippets.

@godkinmo
Created February 4, 2020 03:35
Show Gist options
  • Save godkinmo/53de1422ca2249b82fd9c72af3c697b3 to your computer and use it in GitHub Desktop.
Save godkinmo/53de1422ca2249b82fd9c72af3c697b3 to your computer and use it in GitHub Desktop.
An bash function for opening the project's database in TablePlus config in zshconfig
function dbopen() {
if [ -d '/Applications/TablePlus.app' ]; then
DRIVER=$(grep -m1 DB_CONNECTION .env | cut -d '=' -f2)
HOST=$(grep -m1 DB_HOST .env | cut -d '=' -f2)
USER=$(grep -m1 DB_USERNAME .env | cut -d '=' -f2)
PASSWORD=$(grep -m1 DB_PASSWORD .env | cut -d '=' -f2)
DATABASE=$(grep -m1 DB_DATABASE .env | cut -d '=' -f2)
if [ $DRIVER = "sqlite" ]; then
open $DATABASE
else
open $DRIVER://$USRE:$PASSWORD@$HOST/$DATABASE
fi
else
echo "This command uses TablePlus, are you sure it's installed?"
echo "Install here: https://tableplus.com/"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment