我正在尝试从Skim wiki运行此脚本
#!/bin/bash
file="$1"
line="$2"
[ "${file:0:1}" == "/" ] || file="${PWD}/$file"
exec osascript \
-e "set ESC to ASCII character 27" \
-e "tell application \"Vim\" to activate" \
-e "tell application \"System Events\"" \
-e " tell process \"Vim\"" \
-e " keystroke ESC & \":set hidden\" & return " \
-e " keystroke \":if bufexists('$file')\" & return " \
-e " keystroke \":exe \\\":buffer \\\" . bufnr('$file')\" & return " \
-e " keystroke \":else \" & return " \
-e " keystroke \": edit ${file// /\\\\ }\" & return " \
-e " keystroke \":endif\" & return " \
-e " keystroke \":$line\" & return " \
-e " keystroke \"zO\" " \
-e " end tell" \
-e "end tell"
如果我尝试从命令行运行它:
# Go to line 20 of some_file
$ ./that_script "some_file" 20
我收到以下错误:
56:64: execution error: File Vim wasn’t found. (-43)
尝试
我尝试了各种方法:
tell application \"vim\" to activate <-- File vim wasn't found
tell application \"/usr/bin/vim\" to activate <-- this raises a 10810 error
tell application \"/path/to/my/own/compiled/vim\" <-- this raises a 10810 error
客观的
我正在尝试与从终端而不是 GUI 运行的 Vim 实例“交谈”。