terminal - 如何通过 AppleScript Terminal.app 复制屏幕上的当前文本?

标签 terminal applescript

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

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

我可以在命令行上执行吗?

整个历史日志怎么样?

最佳答案

从命令行复制当前选定的 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

关于terminal - 如何通过 AppleScript Terminal.app 复制屏幕上的当前文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/529143/

相关文章:

ssh - 如何为集群创建自动 "ssh"

python - Heroku Local 不工作?

c - 如何调用 EOF 到标准输入

macos - 使用终端查找文件夹内的文本

applescript - 如何在执行脚本之前等待网页完全加载?

macos - AppleScript:如何在 Apple Notes 中自动创建新笔记

cocoa - 使用参数从 Cocoa App 执行 Applescript

java - 写入/打印到终端底部

objective-c - NSAppleScript 和线程安全

applescript - 在 AppleScript 中使用的 iMovie 项目文件夹的正确路径是什么