9

In the Terminal I use open . to open the current directory using Finder.

Open folders in new tabs settings is set in the Finder, yet it opens a new window every time. By the end of a project/day I have dozens of these windows open.

How do I get the Finder to open a new tab, instead of a new window when using open . in the Terminal?

Nick
  • 191
  • 1
  • 3
  • I don't think `open` can handle that for the moment. – Matthieu Riegler Dec 15 '13 at 18:03
  • Related: http://apple.stackexchange.com/questions/106131/make-folders-opened-by-external-apps-open-in-a-new-finder-tab-rather-than-a-wind – Nick Dec 24 '13 at 17:52
  • 1
    Perhaps, some AppleScript hacking could resolve this problem. (sorry, I don't have Mavericks to test it, but you can try to adapt the solution [here](http://blog.qsapp.com/post/66560143350/opening-folders-in-finder-tabs)). – Igor Hatarist Feb 04 '14 at 09:47
  • ...and hack your shell to replace the default "open ." behaviour with this applescript launch. – Igor Hatarist Feb 04 '14 at 10:41

2 Answers2

2

Probably a bit late, but in case other people are still searching for this. In macOS Big Sur this works: System preferences > General > Prefer tabs > select always from the dropdown menu.

Now open . will open in a new tab in an existing Finder window. It also works from iTerm.

MihaiL
  • 121
  • 1
  • 1
    People are still looking and thanks for adding that bit :) – BiGYaN Feb 11 '22 at 23:54
  • 1
    on macOS Ventura: System Settings > Desktop & Dock > Windows & Apps > Prefer tabs when opening documents > Always – OndroNR Jan 05 '23 at 12:53
  • While having **Preferences > Desktop & Dock > Automatically hide and show the menu bar** set to on Finder still would not open in a tab. I figured out you also have to set **Finder > Settings > General > Open folders in tabs instead of new windows** to on as well. This made `open .` open the current Finder window and open `.` in a new tab in that window. (in Ventura) – aubreypwd Jul 27 '23 at 17:01
2

You cannot use open . to open a new tab in Finder, though it is possible to open a new tab using AppleScript - from How do you duplicate current open Finder view in new tab (Mavericks)?

tell application "Finder"
    activate
    set t to target of Finder window 1
    set toolbar visible of window 1 to true
end tell
tell application "System Events"
    keystroke "t" using command down
end tell
tell application "Finder"
    set target of Finder window 1 to t
end tell

Alternatively from http://macscripter.net/viewtopic.php?id=41624

set docs_path to (path to documents folder) as string
set Sat_folder to docs_path & "Sat:"
set ABC_folder to (Sat_folder & "ABC:") as alias

tell application "Finder"
   activate
   open Sat_folder
end tell

tell application "System Events" to keystroke "t" using command down

tell application "Finder"
   set target of front window to ABC_folder
end tell
hanxue
  • 2,940
  • 4
  • 29
  • 53