Last active
February 20, 2023 09:06
-
-
Save CoderPiF/86238712faa40f163ff3f739887530b1 to your computer and use it in GitHub Desktop.
open file with vim in iTerm2 by double click
This file contains hidden or 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 the_path to POSIX path of input | |
set cmd to "vim '" & the_path & "'" | |
set isRunning to (application "iTerm" is running) | |
tell application "iTerm" | |
activate | |
if isRunning then | |
if (count of windows) > 0 then | |
set sess to (current session of (create tab with default profile of current window)) | |
else | |
set sess to (current session of (create window with default profile)) | |
end if | |
else | |
set sess to (current session of current window) | |
end if | |
tell sess | |
write text 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
Thank's for a very helpful script!
I would add a delay until a current window exists in cases when iTerm is not running so that it has time to open a new window:
Result: