命令行 AppleScript 操控 iTerm2

 AppleScript 是什么?

 AppleScript 是 macOS 下可用于操控其他软件的脚本语言。

 

参考链接:https://www.iterm2.com/documentation-scripting.html

下面的命令:打开 iterm2, 并且 运行命令 "tail -f /Users/ruby/index.html",然后进入全屏模式

tell application "iTerm"
	activate
	create window with default profile command "tail -f /Users/ruby/index.html"
end tell

tell application "System Events"
	tell process "iTerm2"
		key down command
		keystroke return
		key up command
	end tell
end tell

 把上面的代码保存为 xx.scpt 文件,双击打开后,如下,点击上面第三个按钮即可运行:

 

另外,使用这个特性需要修改一下系统设置:打开 System Preference -> Privacy -> Accessibility -> 勾选上 "Script Editor", 如果没有这个则点 "+" 在 /Applications/Utility 里面选择

 

系统样例(打开 Script Editor 然后看右上角)

 

其他资料:

AppleScript 官方文档:https://www.iterm2.com/documentation-scripting.html

 

转载于:https://www.cnblogs.com/eleven24/p/10274757.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值