Last active
December 24, 2016 01:30
-
-
Save brablc/b2f40c2f652e420484d2 to your computer and use it in GitHub Desktop.
Open Vim in Terminal (iTerm) from Finder - copied from http://thepugautomatic.com/2015/02/open-in-iterm-vim-from-finder/ and updated to open in the current terminal
This file contains 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} | |
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) | |
tell myTerm | |
set mySession to (make new session at the end of sessions) | |
tell mySession to exec command cmd | |
end tell | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok guys I took the challenge as well and here is my gist : https://gist.github.com/chaadow/5e8ed49c333008eec0c3ced07451ee48
It works for El Capitan.
It handles 2 scenarios basically :
Even though the script feels repetitive, this is the only and simplest way I found to handle most of the edge cases.
Alternatively, according to the iterm documentation, there is a
is at shell prompt
option, that allows to know if the current session if "free", so we can run the vim command without the need of creating a new tab each time.However it requires installing the shell integration utiliites inside of iTerm, and this is not a "simple solution".
Cheers.