Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use Applescript to launch files in vim via iTerm
on run {input, parameters}
set cmd to "vim -c startinsert"
if input is not in {} then
set myPath to POSIX path of input
set cmd to "vim " & quote & myPath & quote
end if
tell application "iTerm"
activate
set myTerm to (current terminal)
try
tell myTerm
set mySession to (make new session at the end of sessions)
tell mySession to exec command cmd
end tell
on error
set myTerm to (make new terminal)
tell myTerm
set mySession to (make new session at the end of sessions)
tell mySession to exec command cmd
end tell
end try
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment