Refs:
- https://stackoverflow.com/questions/7171725/open-new-terminal-tab-from-command-line-mac-os-x
- https://stackoverflow.com/questions/48591219/open-multiple-terminal-windows-mac-using-bash-script
------------------------------------------------------------------------------------------------
Open 3 tabs and run commands
```
function tab() {
while read hostname
do
{
osascript 2>/dev/null <<EOF
tell application "System Events"
tell process "Terminal" to keystroke "t" using command down
end
tell application "Terminal"
activate
#do script with command "cd \"$PWD\"; $*" in window 1
do script with command "ssh root@$hostname" in window 1
end tell
EOF
}
done < "$1"
}
```
Usage with NPM scripts
```
"scripts": {
"dev": "yarn clean && yarn open-tab-build-local && yarn run-svr",
"build-local": "ENV=local-dev webpack --config src/build/webpack.client.config.js",
"run-svr": "ENV=local-dev node ./src/server/server.js",
"open-tab-build-local": "osascript -e 'tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down' -e 'tell application \"Terminal\" to do script with command \"yarn build-local\" in window 1'"
}
留言列表