多年來,我一直使用以下AppleScript在iTerm2中的vim中打開txt文件,但自iTerm 2.9.2(又名iTerm3)以來,它已被破壞。任何人都可以建議如何更新這個AppleScript,以便它再次工作?如何更新蘋果腳本以在iTerm3 vim中打開txt文件
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
此代碼看起來像它來自Automator,是否正確?如果不是,你如何執行腳本? –
是的,在Automator中,將AppleScript保存爲應用程序,然後將該應用程序與txt文件相關聯。在Finder中雙擊txt文件,它將在iTerm的vim中打開。 –
在這個Automator工作流程中還有其他任何操作,或者只有您在此處運行的單個AppleScript? –