Created
October 10, 2018 20:58
-
-
Save mikesale/f265890a751f861bb314d346650ca499 to your computer and use it in GitHub Desktop.
AppleScript for Automator application to open file in Neovim in an iTerm window.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
tell application "iTerm" | |
create window with default profile | |
tell current session of current window | |
write text myCmd | |
end tell | |
end tell | |
return input | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment