【问题标题】:On osx, how to open new iterm terminal tab from one script then run command in that temrinal window在 osx 上,如何从一个脚本打开新的 iterm 终端选项卡,然后在该终端窗口中运行命令
【发布时间】:2015-01-07 13:37:53
【问题描述】:

我正在运行 osx。我有一个运行完整堆栈的脚本,然后在最后运行 grunt。我希望能够在单独的终端选项卡中分离正在运行的 grunt,我正在使用 iterm。

我尝试过类似的东西

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

有什么想法吗?

【问题讨论】:

    标签: macos terminal iterm


    【解决方案1】:

    这应该为你做(显然改变目录和命令):

    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'
    

    这是something I wrote 的略微修改版本,添加了对 RStudio 的 iTerm 支持。

    【讨论】:

      【解决方案2】:

      像这样:

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

      date 替换为您希望它执行的任何操作。

      【讨论】:

      • 抱歉,我错过了您问题中的iterm,但我会留下它,因为它可能对其他人有所帮助。
      • 我没有 iTerm,但您可以调整此处的代码并将其包装在 osascript 调用中,就像我为标准 Apple 术语所做的那样...code.google.com/p/iterm2/wiki/AppleScript
      猜你喜欢
      • 2021-10-05
      • 2010-12-08
      • 1970-01-01
      • 2020-05-14
      • 1970-01-01
      • 1970-01-01
      • 2010-11-14
      • 2013-11-18
      • 2021-12-09
      相关资源
      最近更新 更多