Mat*_*yan 8 vim iterm file-association
我知道 MacVim,虽然它非常好,但我经常在终端中。当我可以留在一个程序中时,为什么要运行两个程序?
所以问题是,我怎样才能让 VIM(在 iTerm2 中运行)成为默认的文本编辑器?
请在此处查看我的答案,但请改用Automator 中的Run AppleScript操作并使用以下 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)
如果没有,这将打开一个新的 iTerm 窗口,否则将打开一个新选项卡,并在其中打开文件。结果:

| 归档时间: |
|
| 查看次数: |
8577 次 |
| 最近记录: |