环境
- macOS
- Alfred5
- neoVim
- iTerm2
步骤
-
Alfred5创建新的工作流
-
创建输入组件
inputs --> Keyword 拖进caves,双击编辑
这里的Keyword我设置的是vim
,按照自己的喜好修改 -
创建脚本组件
Actions --> Run Script
这一步和下一步无所谓先后,如果不知道为啥这么写,先看下一步
-
applescript
- 打开当前工作流所在文件夹:点击上面标注的图标
- 创建文件:
openVim.applescript
- 用文本编辑器或者脚本编辑器(macOS自带)打开
- 输入脚本,保存关闭
on run argv set useFullScreen to true -- 默认全屏 if (count of argv) is not 0 then set argValue to item 1 of argv as integer if argValue is 0 then set useFullScreen to false end if end if tell application "iTerm" activate create window with default profile -- set to fullscreen if useFullScreen then tell application "System Events" tell process "iTerm2" click (first menu item whose name is "Toggle Full Screen") of menu "View" of menu bar 1 end tell end tell end if delay(0.8) -- open nvim tell current session of current window write text "nvim" --命令,如果打开vim改成相应的命令 end tell end tell end run
使用
vim [0/1]
呼出alfred之后输入vim
即可打开neoVIm
默认全屏打开,如果Keyword后面加入参数0
,就是默认窗口大小打开;如果参数是1
,也是全屏打开。
参数
缺省/1
: 全屏打开neovim0
: 默认大小窗口打开neovim