Refs:

- https://superuser.com/questions/117642/open-up-3-terminals-run-different-commands-from-all-for-each-of-them-to-set-up

- 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'"

}

 

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Foxbrush 的頭像
    Foxbrush

    Foxbrush

    Foxbrush 發表在 痞客邦 留言(0) 人氣()