Skip to content

Instantly share code, notes, and snippets.

@goerz
Created May 28, 2019 22:26
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 goerz/52a0f9e6314d520d04fdfc7ca9a13e14 to your computer and use it in GitHub Desktop.
Save goerz/52a0f9e6314d520d04fdfc7ca9a13e14 to your computer and use it in GitHub Desktop.
Use Neovim in iTerm as a GUI editor
on run {input, parameters}
set cmd to ""
if input is not {} then
set filePath to POSIX path of input
set cmd to ":e " & filePath
end if
tell application "iTerm"
set mywindow to (create window with profile "neovim")
tell the current session in mywindow
write text cmd
end tell
try
repeat
tell the current session in mywindow
-- querying the id will raise an exception if the window is closed
set dummy to id
delay 0.5
end tell
end repeat
on error errStr number errorNumber
-- pass
end try
end tell
end run
@goerz
Copy link
Author

goerz commented May 28, 2019

Create a new app in Automator, add a “Run Applescript” action, and paste the script.

Improves on https://blog.schembri.me/post/neovim-everywhere-on-macos/ by blocking execution until the iTerm window is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment