-- Adapted from these sources: | |
-- http://peterdowns.com/posts/open-iterm-finder-service.html | |
-- https://gist.github.com/cowboy/905546 | |
-- | |
-- Modified to work with files as well, cd-ing to their container folder | |
on run {input, parameters} | |
tell application "Finder" | |
set my_file to first item of input | |
set filetype to (kind of (info for my_file)) | |
-- Treats OS X applications as files. To treat them as folders, integrate this SO answer: | |
-- http://stackoverflow.com/a/6881524/640517 | |
if filetype is "Folder" or filetype is "Volume" then | |
set dir_path to quoted form of (POSIX path of my_file) | |
else | |
set dir_path to quoted form of (POSIX path of (container of my_file as string)) | |
end if | |
end tell | |
CD_to(dir_path) | |
end run | |
on CD_to(theDir) | |
tell application "iTerm" | |
activate | |
set go_dir to "cd " & theDir | |
set newWindow to (create window with default profile) | |
tell current session of first window | |
write text go_dir | |
end tell | |
end tell | |
end CD_to |
This comment has been minimized.
This comment has been minimized.
@revaxarts Try this snippet:
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Seems
to
seems to work in my case, both for files and folders |
This comment has been minimized.
This comment has been minimized.
Thank's @revaxarts |
This comment has been minimized.
This comment has been minimized.
use |
This comment has been minimized.
This comment has been minimized.
Is this working on OSX 10.12.4 for anyone? It appears that "first item of input" causes the script to fail. For testing, I added "Get Specified finder items" in the workflow within Automator. Script receives input from that action and works correctly. However, when you click on the application, you just get a message "The action "Run Applescript" encountered an error" I created this as a service. I can right click and select the service on the folder. It works and the folder is opened in iTerm as a . new tab. |
This comment has been minimized.
This comment has been minimized.
Took me trying a few other versions before fining this one. Awesome update to the two previous versions. Thanks |
This comment has been minimized.
This is working but it opens the parent directory. Also it always creates a new window instead of a new tab. Any idea?