Skip to content

Instantly share code, notes, and snippets.

@macmule
Created November 21, 2021 16:48
Show Gist options
  • Select an option

  • Save macmule/f5e49cf2a362fac8ddb4efa00471c508 to your computer and use it in GitHub Desktop.

Select an option

Save macmule/f5e49cf2a362fac8ddb4efa00471c508 to your computer and use it in GitHub Desktop.
#!/bin/bash
####################################################################################################
#
# License: https://macmule.com/license/
#
####################################################################################################
#
# DEFINE VARIABLES & READ IN PARAMETERS
#
####################################################################################################
# HARDCODED VALUE FOR "PATHTOEXTENSION" IS SET HERE
pathToExtension=""
# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 4 AND, IF SO, ASSIGN TO "PATHTOEXTENSION"
if [ "$4" != "" ] && [ "$pathToExtension" == "" ];then
pathToExtension=$4
fi
# Error if variable appName is empty
if [ "$pathToExtension" == "" ]; then
echo "Error: No value was specified for the pathToExtension variable..."
exit 1
fi
####################################################################################################
### Launch Safari if not open
osascript -e 'tell application "Safari"
activate
end tell'
### Prompt the user to install the extension given @ $4
osascript -e 'tell application "Safari"
open "'"$pathToExtension"'"
end tell'
### Exit silently, as will error if exists & if times out for whatever reason
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment