- 安装NeoVim和iTerm2 (实际上自带的Terminal也可以,这里以iTerm2为例)
- 打开Automator,选择创建Application
- 添加步骤
Run AppleScript
,使用下面的脚本:
on run {input, parameters}
set nvim to "/usr/local/bin/nvim "
set filepaths to ""
if input is not {} then
repeat with currentFile in input
set filepaths to filepaths & quoted form of POSIX path of currentFile & " "
end repeat
end if
if application "iTerm" is running then
tell application "iTerm"
create window with default profile command nvim & filepaths
end tell
else
tell application "iTerm"
tell current session of current window
write text nvim & filepaths
end tell
end tell
end if
end run
- 将文件保存到
/Applications
下 - (optional)添加NeoVim图标
- 下载neovim-mark.png
- 复制到剪切板
- 右键NeoVim应用,选择
Get Info
- 点击上面的icon,粘贴
- 右键想用neovim打开的文档,选
Open With
→Other...
→ 选择NeoVim,勾选`Always Open With
参考:https://gregrs-uk.github.io/2018-11-01/open-files-neovim-iterm2-macos-finder/`