-
-
Save robbplo/9ed6fdaf2949b6e457db5d2ab1ae58be to your computer and use it in GitHub Desktop.
fish function of AlexVanderbist/opendb.sh
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 opendb | |
[ ! -f .env ] && { echo "No .env file found."; exit 1; } | |
set DB_CONNECTION (grep DB_CONNECTION .env | grep -v -e '^\s*#' | cut -d '=' -f 2-) | |
set DB_HOST (grep DB_HOST .env | grep -v -e '^\s*#' | cut -d '=' -f 2-) | |
set DB_PORT (grep DB_PORT .env | grep -v -e '^\s*#' | cut -d '=' -f 2-) | |
set DB_DATABASE (grep DB_DATABASE .env | grep -v -e '^\s*#' | cut -d '=' -f 2-) | |
set DB_USERNAME (grep DB_USERNAME .env | grep -v -e '^\s*#' | cut -d '=' -f 2-) | |
set DB_PASSWORD (grep DB_PASSWORD .env | grep -v -e '^\s*#' | cut -d '=' -f 2-) | |
set DB_URL "$DB_CONNECTION://$DB_USERNAME:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_DATABASE" | |
echo "Opening $DB_URL" | |
open $DB_URL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment