【发布时间】:2020-05-24 23:19:29
【问题描述】:
我正在使用以下自动机苹果脚本,因此当我将文件拖到停靠图标中时,它会在 vim 中打开该文件:
on run {input, parameters}
set filename to POSIX path of input
set cmd to "clear && 'vim' '" & filename & "' && exit"
tell application "iTerm"
set newWindow to (create window with default profile)
tell current session of newWindow
write text cmd
end tell
end tell
end run
但是,我还希望允许单击图标本身以打开 vim 而没有任何文件,即运行 $vim。我将如何更改上述脚本以便:
- 如果传递了一个文件名,我用那个文件打开 vim,
vim filename - 如果没有传递文件名(图标只是双击),它只是打开 vim,
vim?
【问题讨论】:
标签: vim applescript automator