Last active
January 21, 2023 15:52
-
-
Save rockyzhang24/4cebc482be5850d2c690dd31a42dc868 to your computer and use it in GitHub Desktop.
A macOS service: in Finder, open the selected files with vim in iTerm
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" | |
activate | |
# Get the path of the target files. | |
set filesPathsToEdit to "" | |
set numItems to the count of items of input | |
repeat with x from 1 to numItems | |
set posixPath to quoted form of POSIX path of item x of input | |
set filesPathsToEdit to filesPathsToEdit & " " & posixPath | |
end repeat | |
# Open the target files in vim in a new iTerm window | |
set new_term to (create window with default profile) | |
tell new_term | |
tell the current session | |
write text "nvim " & filesPathsToEdit | |
end tell | |
end tell | |
end tell | |
end if | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment