Skip to content

Instantly share code, notes, and snippets.

@nickclasener
Forked from AlexVanderbist/opendb.sh
Created September 19, 2020 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickclasener/21c4a5db2e2fd4d104d6612928b12f57 to your computer and use it in GitHub Desktop.
Save nickclasener/21c4a5db2e2fd4d104d6612928b12f57 to your computer and use it in GitHub Desktop.
`opendb` command - opens the database for a Laravel app in your GUI
opendb () {
[ ! -f .env ] && { echo "No .env file found."; exit 1; }
DB_CONNECTION=$(grep DB_CONNECTION .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_HOST=$(grep DB_HOST .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_PORT=$(grep DB_PORT .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_DATABASE=$(grep DB_DATABASE .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_USERNAME=$(grep DB_USERNAME .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_PASSWORD=$(grep DB_PASSWORD .env | grep -v -e '^\s*#' | cut -d '=' -f 2-)
DB_URL="${DB_CONNECTION}://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}"
echo "Opening ${DB_URL}"
open $DB_URL
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment