Created
February 4, 2020 03:35
-
-
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
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
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