Skip to content

Instantly share code, notes, and snippets.

@sdkks
Last active May 13, 2023 14:16
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save sdkks/a017564ea65a781a9ce416d716e08f1e to your computer and use it in GitHub Desktop.
Save sdkks/a017564ea65a781a9ce416d716e08f1e to your computer and use it in GitHub Desktop.
Open File with iTerm2 + nvim on OSX using Automator
on run {input, parameters}
-- If run without input, open random file at $HOME
try
set filename to POSIX path of input
on error
set filename to "nvim-" & (do shell script "date +%F") & "__" & (random number from 1000 to 9999) & ".txt"
end try
-- Set your editor here
set myEditor to "/usr/local/bin/nvim"
-- Open the file and auto exit after done
set myCmd to myEditor & " " & quote & filename & quote & " &&exit"
-- I am using iTerm2
tell application "iTerm"
-- I would want my editor to be a new window, no new tab
create window with profile "sh"
tell current session of current window
write text myCmd
end tell
end tell
return input
end run
@mikesale
Copy link

Thanks for this!

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