

Opening the current Finder directory in iTerm2 - peter_l_downs
http://peterdowns.com/posts/open-iterm-finder-service.html

======
tzs
I use Go2Shell, which is free on the Mac App Store:
<http://itunes.apple.com/us/app/go2shell/id445770608?mt=12>

It adds a button to the toolbar to Finder windows. Click that to open a
terminal on the directory shown in the window.

There are other similar toolbar add ons available, which I've used and were
happy with, such as cdto: <http://code.google.com/p/cdto/>

I use Go2Shell now because it is on the App Store, so that I don't have to
worry about checking for updates.

------
Sidnicious
The terminal app built into OS X (newer versions, at least) lets you drag a
folder to its icon to open a new terminal at that path.

It looks like iTerm2 _almost_ does it — if you drag a directory to its icon it
tries to execute it (which fails).

EDIT: actually, it looks like iTerm master supports this too:
[https://github.com/gnachman/iTerm2/blob/194678de81100cb17dad...](https://github.com/gnachman/iTerm2/blob/194678de81100cb17dad422efcb65400e23910a6/iTermApplicationDelegate.m#L437)

…but it doesn’t work for directories with spaces and other special characters.
Looks like a bug.

EDIT 2: Pull request sent: <https://github.com/gnachman/iTerm2/pull/78>

~~~
gnachman
Merged. Thanks :)

~~~
Sidnicious
Awesome!

------
johncoltrane
I use a droplet in the Finder window for that. It's called Open iTerm here.app
and I have no idea where I've found it. Google gives quite a bunch of results,
though.

Before that, I've used another similar droplet called Open Terminal here.app.

In iTerm I use

    
    
        $ open .
    

to open the current directory in a Finder window.

I also have a little bash function to `cd` into the topmost Finder window:

    
    
        cdf () {
          CURRFOLDERPATH=$( /usr/bin/osascript <<"    EOT"
            tell application "Finder"
              try
                  set currFolder to (folder of the front window as alias)
              on error
                  set currFolder to (path to desktop folder as alias)
              end try
              POSIX path of currFolder
            end tell
            EOT
          )
          echo "cd to \"$CURRFOLDERPATH\""
          cd "$CURRFOLDERPATH"
        }

------
protomyth
I put an icon on the finder window so I just click it and get a terminal open
to the directory.

[http://maururu.net/2007/enhanced-open-terminal-here-for-
leop...](http://maururu.net/2007/enhanced-open-terminal-here-for-leopard/)

------
epochwolf
If you want do this with Terminal.app instead, there is a setting for this.

Open the keyboard preferences, go to the "Keyboard Shortcuts" tab, click
"Services" in the left panel and in the right panel under "Files and Folders",
there is an option for "New Terminal at Folder".

Then you can right click on a folder and launch a terminal.

Visual: [http://osxdaily.com/2011/12/07/open-a-selected-finder-
folder...](http://osxdaily.com/2011/12/07/open-a-selected-finder-folder-in-a-
new-terminal-window/)

------
mistercow
I achieved something similar in bash, in a terminal-agnostic way a while back.
I have this script saved at ~/cdf.scpt : <https://gist.github.com/2037421>

Then my .bash_profile contains the line:

    
    
        alias cdf='cd "`osascript ~/cdf.scpt`"'
    

Now if I type "cdf" in a terminal window, it will automatically cd to the
directory of the front-most Finder window.

------
LiveTheDream
I use Alfred (<http://www.alfredapp.com/>), which gives you a keyboard
shortcut (opt-cmd-\\) that gives you the ability to open a terminal at the
currently selected Finder item.

~~~
Steveism
This is another good Alfred extension that does basically the same thing but
with an AppleScript: <https://github.com/pcal/alfred-terminal-here>

------
mrpollo
I found this years ago on a forum cant seem to find the link but I'm pretty
sure its out there and has been posted here before

<https://gist.github.com/2037827>

------
haroldp
Wouldn't this be best as a contextual menu extension? Right-click and select
open-in-iTerm.

Is anyone still coding those? There was such a huge ecosystem of them forever
ago for OS8/9, but I don't see them anymore.

~~~
peter_l_downs
This is as close as I could get.

------
bickfordb
You can also just write "open ." in an iTerm window

~~~
dave1010uk
Whilst this is the opposite of what the post is suggesting, it's a useful
thing to know.

If you use Nautilus (e.g. Ubuntu), "nautilus ." works. I guess "explorer ."
would work in Windows.

------
LuxuryMode
the link to "solarized" just links to iterm2's website...

~~~
peter_l_downs
Thanks for pointing this out — fixed.

