Skip to content

Instantly share code, notes, and snippets.

@mstroeck
Created November 12, 2015 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mstroeck/f06753dce2c06200692d to your computer and use it in GitHub Desktop.
Save mstroeck/f06753dce2c06200692d to your computer and use it in GitHub Desktop.
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