Skip to content

Instantly share code, notes, and snippets.

@dpo
Created September 18, 2019 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpo/3f39255e33ad7aabad3169be543db0d4 to your computer and use it in GitHub Desktop.
Save dpo/3f39255e33ad7aabad3169be543db0d4 to your computer and use it in GitHub Desktop.
#!/bin/bash
file="$1"
line="$2"
[ "${file:0:1}" == "/" ] || file="${PWD}/$file"
exec osascript \
-e "set ESC to ASCII character 27" \
-e "tell application \"/Users/dpo/bin/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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment