【发布时间】:2016-02-27 05:43:04
【问题描述】:
多年来,我一直使用以下 AppleScript 在 iTerm2 中的 vim 中打开 txt 文件,但自从 iTerm 2.9.2(又名 iTerm3)以来,它就坏了。谁能建议如何更新这个 AppleScript 让它再次工作?
on run {input, parameters}
if (count of input) > 0 then
tell application "System Events"
set runs to false
try
set p to application process "iTerm"
set runs to true
end try
end tell
tell application "iTerm"
activate
if (count of terminals) = 0 then
set t to (make new terminal)
else
set t to current terminal
end if
tell t
tell (make new session at the end of sessions)
exec command ("vim \"" & POSIX path of first item of input as text) & "\""
end tell
if not runs then
terminate first session
end if
end tell
end tell
end if
end run
我最初是从 http://earthwithsun.com/questions/283418/how-can-i-make-terminal-vim-my-default-editor-application-in-mac-os-x 复制脚本,但我没有任何 AppleScript 经验。
非常感谢任何帮助! 乙
【问题讨论】:
-
这段代码看起来像是来自 Automator,对吗?如果没有,如何执行脚本?
-
是的,在 Automator 中,将 AppleScript 保存为应用程序,然后将该应用程序与 txt 文件相关联。在finder中双击txt文件,在iTerm的vim中打开。
-
此 Automator 工作流程中是否还有其他操作,或者只是您在此处拥有的单个 Run AppleScript?
标签: vim applescript iterm2