B-3*_*-30 4 vim applescript iterm2
多年来我一直在使用以下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
Run Code Online (Sandbox Code Playgroud)
我最初从http://earthwithsun.com/questions/283418/how-can-i-make-terminal-vim-my-default-editor-application-in-mac-os-x复制了脚本,但我没有AppleScript任何经验.
任何帮助最感谢!乙
使用@ dusty的链接,我建议您将Run AppleScript Action的整个代码部分更改为:
on run {input, parameters}
tell application "iTerm"
activate
if (count of windows) = 0 then
set t to (create window with default profile)
else
set t to current window
end if
tell t
tell current session
write text ("vim \"" & POSIX path of first item of input as text) & "\""
end tell
end tell
end tell
end run
Run Code Online (Sandbox Code Playgroud)
它似乎在我的机器上工作,但我从不使用vim,所以我不确定这是否会给你准确的你想要的东西.
祝好运,
| 归档时间: |
|
| 查看次数: |
796 次 |
| 最近记录: |