Skip to content

Instantly share code, notes, and snippets.

@jiz4oh
Last active February 6, 2022 05:29
Show Gist options
  • Save jiz4oh/baae917d748183c4534f2d7e0d57d4eb to your computer and use it in GitHub Desktop.
Save jiz4oh/baae917d748183c4534f2d7e0d57d4eb to your computer and use it in GitHub Desktop.
how to open file in vim through Finder
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 "vim-" & (do shell script "date +%F") & "__" & (random number from 1000 to 9999) & ".txt"
end try
-- Set your editor here
set myEditor to "${EDITOR:-vim}"
-- 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