Use AppleScript in a Shell Script
You can write AppleScript as Shell Scripts just as you would with any other bash/zsh file. The key requirement is that you start the file with the appropriate shebang line:
#! /usr/bin/env osascript
Then make sure you correctly grab your arguments
--grabs the first argumentset myArgument to (item 1 of argv)
#! /usr/bin/env osascript-- usage: `open-tab twitter`-- Opens chrome, checks if twitter is already open,-- switches to existing tab. Opens a new tab it not.on run argvset address to (item 1 of argv)tell application "Google Chrome"activateif not (exists window 1) then reopenrepeat with w in windowsset i to 1repeat with t in tabs of wif URL of t contains address thenset active tab index of w to iset index of w to 1returnend ifset i to i + 1end repeatend repeatopen location "http://" & addressend tellend run