Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Applescript to use in automator to open a file in Terminal in neovim
on run {input}
set filename to POSIX path of input
set cmd to "clear;cd $(dirname " & filename & ");nvim " & quoted form of filename & "; exit"
tell application "System Events" to set terminalIsRunning to exists application process "Terminal"
tell application "Terminal"
activate
if terminalIsRunning is true then
set newWnd to do script with command cmd
else
do script with command cmd in window 1
end if
end tell
end run
@matthewshannon

This comment has been minimized.

Copy link

matthewshannon commented Sep 18, 2019

set filename to quoted form of POSIX path of input
-- support both directories and file names with spaces within
set cmd to "clear;cd \"$(dirname " & filename & ")\";vim " & filename & "; exit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.