Skip to content

Instantly share code, notes, and snippets.

@youzi
Last active April 6, 2018 14:43
Show Gist options
  • Save youzi/8624acaff807ba95a1935de6fe8993a8 to your computer and use it in GitHub Desktop.
Save youzi/8624acaff807ba95a1935de6fe8993a8 to your computer and use it in GitHub Desktop.
Open input file in active vim session or new vim session in iTerm
tell application "iTerm"
try
repeat with termWindow in windows
tell termWindow
repeat with termTab in tabs
tell termTab
repeat with termSession in sessions
tell termSession
if name contains " vim " then
write text ":e " & POSIX path of input
activate
tell termWindow
select
end tell
tell termTab
select
end tell
select
return
end if
end tell
end repeat
end tell
end repeat
end tell
end repeat
end try
create window with default profile
tell front window
tell current session
write text "vim " & quote & POSIX path of input & quote
end tell
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment