Created
July 15, 2020 06:43
-
-
Save usualwitch/7544d22548bef60f9d51691ef69b9849 to your computer and use it in GitHub Desktop.
Automator application to open file in terminal vim.
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 didThese to {} | |
repeat with f in input | |
set f to (f as text) | |
if f ends with ":" then | |
if f is in didThese then --check to see if we did this already | |
--ignore | |
else | |
tell application "Terminal" | |
do script "cd " & quoted form of POSIX path of f | |
end tell | |
set didThese to (didThese & f) --load into memory for subsequent iterations of loop | |
end if | |
else | |
--first get containing folder, then use that | |
tell application "Finder" to set g to ((container of alias f) as alias as text) | |
if f is in didThese then | |
--ignore | |
else | |
tell application "Terminal" | |
do script "cd " & quoted form of POSIX path of g & "; vim " & quoted form of POSIX path of f | |
end tell | |
set didThese to (didThese & g) | |
end if | |
end if | |
end repeat | |
activate application "Terminal" | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment