0

I am running osx. I have a script which runs the full stack then runs grunt at the end. I want to be able to separate running grunt in a separate terminal tab, i am using iterm.

I have tried something like

open -a Terminal "cd ~/dev/work/poc/user-interface/src/main/webapp; grunt"

any ideas?

thiswayup
  • 2,069
  • 8
  • 32
  • 52

2 Answers2

2

This should do it for you (obviously change dir & command):

osascript -e '
  tell app "iTerm"
    activate
    tell the first terminal
      launch session "Default Session"
      tell the last session
        set name to "New Session"
        write text "cd /usr/bin; ls"
      end tell
    end tell
  end tell'

It's a slightly modified version of something I wrote to add iTerm support for RStudio.

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
1

Like this:

#!/bin/bash
osascript -e '
   tell application "Terminal"
   do script "date"
   activate
   end tell'

Replace date with whatever you want it to do.

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • 1
    Sorry, I missed the `iterm` in your question, but I will leave it as it may help other folk. – Mark Setchell Jan 07 '15 at 13:51
  • I don't have iTerm, but you can maybe adapt the code here and wrap it in the `osascript` call like I did for the standard Apple term... https://code.google.com/p/iterm2/wiki/AppleScript – Mark Setchell Jan 07 '15 at 14:59