6 ms·
Opening the current Finder directory in iTerm2
- mistercow 15y agoI 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 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 15y agoI use Alfred (http://www.alfredapp.com/ 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 15y agoThis is another good Alfred extension that does basically the same thing but with an AppleScript: https://github.com/pcal/alfred-terminal-here https://github.com/pcal/alfred-terminal-here
- deleted 15y ago[deleted]
- bickfordb 15y agoYou can also just write "open ." in an iTerm window
- Sidnicious 15y agoWon’t that open the CWD (in that terminal) in a new Finder window?
- mikey_p 15y agoThat's the reverse of that the author is trying to do, which is open a terminal window, when he has a Finder window open.
- dave1010uk 15y agoWhilst 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.
- heliostatic 15y agoThat was my initial thought, but he's describing the reverse: browse to a folder in Finder, then open a terminal with the path set to that directory.
- Sidnicious 15y agoThe 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/194678de81100cb17dad422efcb65400e23910a6/iTermApplicationDelegate.m#L437 https://github.com/gnachman/iTerm2/blob/194678de81100cb17dad... …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 https://github.com/gnachman/iTerm2/pull/78
- peter_l_downs 15y agoVery cool. Thanks for sending in the pull request, I'd love to be able to do that instead of using this Finder service (which is a little hack-y).
- gnachman 15y agoMerged. Thanks :)
- Sidnicious 15y agoAwesome!
- mrpollo 15y agoI 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 https://gist.github.com/2037827
- protomyth 15y agoI 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-leopard/ http://maururu.net/2007/enhanced-open-terminal-here-for-leop...
- LuxuryMode 15y agothe link to "solarized" just links to iterm2's website...
- peter_l_downs 15y agoThanks for pointing this out — fixed.
- johncoltrane 15y agoI 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" }
- tzs 15y agoI use Go2Shell, which is free on the Mac App Store: http://itunes.apple.com/us/app/go2shell/id445770608?mt=12 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/ 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.
- epochwolf 15y agoIf 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-in-a-new-terminal-window/ http://osxdaily.com/2011/12/07/open-a-selected-finder-folder...
- haroldp 15y agoWouldn'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 15y agoThis is as close as I could get.