From 62522c65c79b18c53ffc0c526ff90c00daad0559 Mon Sep 17 00:00:00 2001 From: Chris Stadler <5268387+cstadler333@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:33:50 +0100 Subject: [PATCH] allow only second argument - allow to omit first argument in favor of automatic "current location" - use api to allow origin and destination as separate optional arguments --- commands/web-searches/google-maps.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/commands/web-searches/google-maps.sh b/commands/web-searches/google-maps.sh index 345205af0..d856d504b 100755 --- a/commands/web-searches/google-maps.sh +++ b/commands/web-searches/google-maps.sh @@ -14,10 +14,14 @@ first_argument=${1// /+} second_argument=${2// /+} -if [ "$1" = "" ]; then - open "https://www.google.com/maps" -elif [ "$2" = "" ]; then - open "https://www.google.com/maps/search/$first_argument" +if [ "$1" != "" ]; then + if [ "$2" = "" ]; then + open "https://www.google.com/maps/dir/?api=1&origin=$first_argument" + else + open "https://www.google.com/maps/dir/?api=1&origin=$first_argument&destination=$second_argument" + fi +elif [ "$1" = "" ] && [ "$2" != "" ]; then + open "https://www.google.com/maps/dir/?api=1&origin=Current+Location&destination=$second_argument" else - open "https://www.google.com/maps/dir/$first_argument/$second_argument" + open "https://www.google.com/maps" fi