【问题标题】:How can I AppleScript Terminal.app to copy the current text on the screen?AppleScript Terminal.app 如何复制屏幕上的当前文本?
【发布时间】:2010-10-06 11:03:57
【问题描述】:

我在 AppleScript 字典中看到当前屏幕的文本价值和历史缓冲区可作为属性使用。

我将如何使用 AppleScript 将当前选定的 Terminal.app 选项卡的内容复制到粘贴缓冲区?

我可以在命令行上做吗?

整个历史记录呢?

【问题讨论】:

  • 您是在查找命令历史记录还是终端缓冲区中的所有内容?
  • 终端缓冲区中的所有内容。命令历史很简单,只是“历史”。有时我想抓取一个异常或日志,但它从屏幕上消失或全选很痛苦。我想制作一个 cmd line 工具来完成它,并可能将它发送给一个新的 gist。

标签: terminal applescript


【解决方案1】:

从命令行复制当前选中的 Terminal.app 的内容:

osascript <<END
  tell application "Terminal"
    tell front window
      set the clipboard to contents of selected tab as text
    end
  end
END

关于历史:

osascript <<END
  tell application "Terminal"
    tell front window
      set the clipboard to history of selected tab as text
    end
  end
END

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-10
    • 2011-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多