Skip to content

Instantly share code, notes, and snippets.

@joeybaker
Created June 14, 2018 18:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeybaker/bcc5dafee758455f2ec80697564f3da0 to your computer and use it in GitHub Desktop.
Save joeybaker/bcc5dafee758455f2ec80697564f3da0 to your computer and use it in GitHub Desktop.
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
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