Add an icon to your finder toolbar to open iTerm in the current folder.
Open iTerm from finder
The code and instructions in this gist are from http://peterdowns.com/posts/open-iterm-finder-service.html. I've had to do this a few times and wanted to distill it the basics.
- Open
Automator
- Create an
Application
- Choose
Actions > Utilities > Run Applescript
- Paste the contents of
open_in_iterm.app
into the window.
- Save the script somewhere convenient
- Find the script, then drag the script onto the Finder window while holding the command key (or in Yosemite, the command + option keys)
|
|
|
on run {input, parameters} |
|
tell application "Finder" |
|
set dir_path to quoted form of (POSIX path of (folder of the front window as alias)) |
|
end tell |
|
CD_to(dir_path) |
|
end run |
|
|
|
on CD_to(theDir) |
|
tell application "iTerm" |
|
activate |
|
|
|
try |
|
set sesh to current session of current terminal |
|
on error |
|
set term to (make new terminal) |
|
tell term |
|
launch session "Default" |
|
set sesh to current session |
|
end tell |
|
end try |
|
|
|
tell sesh |
|
write text "cd " & theDir & ";clear;" |
|
end tell |
|
end tell |
|
end CD_to |
This comment has been minimized.
nhducit commentedJul 26, 2016
I got this error when click on the icon in finder application: "The action “Run AppleScript” encountered an error."