Last active
January 29, 2017 10:25
-
-
Save kennyng/62414e7153af1d6a5097 to your computer and use it in GitHub Desktop.
Open files with Vim (command-line) in default OSX Terminal (VimTerminal) and iTerm (VimTerm).
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} | |
if (count of input) > 0 then | |
tell application "iTerm" | |
if (count of terminals) = 0 then | |
activate | |
end if | |
tell (current terminal) | |
tell (launch session "Default") | |
write text "vim " & (POSIX path of first item of input as text) | |
end tell | |
end tell | |
end tell | |
end if | |
end run |
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 open this_file | |
tell application "System Events" | |
if (count (processes whose name is "Terminal")) is 0 then | |
tell application "Terminal" | |
activate | |
do script with command "vim " & (POSIX path of this_file) in front window | |
end tell | |
else | |
tell application "Terminal" | |
activate | |
tell application "System Events" to tell process "Terminal" to keystroke "t" using command down | |
do script with command "vim " & (POSIX path of this_file) in selected tab of the front window | |
end tell | |
end if | |
end tell | |
end open |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment