多年来,我一直使用以下的AppleScript在iTerm2中打开vim文本文件,但自从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经验。
非常感谢您的帮助! B