Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm currently using this simple command to open web sites from the command line:


but when I open two, even doing


they open in separate Safari windows. How can I open them in the same window as two tabs without changing Safari's settings in any way?

share|improve this question
I just set my safari setting to open new link in same windows and don't have your problem, I think this way is more easier than other –  Am1rr3zA Nov 8 '09 at 19:36
Agreed, it's definitely easier to change the Safari preference. I'd also imagine that you want similar behavior when clicking on links, too. –  Lawrence Velázquez Nov 8 '09 at 23:55

2 Answers 2

Here's how to change Safari's general settings to open new URLs in new tabs:

I don't know if there's a way to do it by specifying an option at the command line.

EDIT: If you'd rather not change your Safari preferences for some reason but still want to be able to open new URLs in tabs from the command line, you could create an AppleScript like this:

-- ~/Library/Scripts/newtab.scpt (or whatever name you'd like)
-- _argv will be the URLs given at the command line
on run _argv
    	tell application "Safari" to activate

    	--repeat for each URL
    	repeat with _i from 1 to length of _argv
    		-- Copy URL to clipboard
    		tell application "Safari" to set the clipboard to item _i of _argv

    		-- Tell Safari to open a new tab, paste the URL, and "hit" Return
    		tell application "System Events"
    			tell process "Safari"
    				tell menu bar 1 to click menu item "New Tab" of menu "File" of menu bar item "File"
    				tell menu bar 1 to click menu item "Open Location…" of menu "File" of menu bar item "File"
    				tell menu bar 1 to click menu item "Paste" of menu "Edit" of menu bar item "Edit"
    				key code 36
    			end tell
    		end tell
    	end repeat
    end try
end run

and define an alias (or shell function, or shell script, or whatever) like this:

alias openurl="osascript ${HOME}/Library/Scripts/newtab.scpt"

and then use it like this:


It's kind of ugly, but it should get the job done. I think. Unless you're really smitten with open.

share|improve this answer
I can confirm, I have that option activated and when doing open it opens the site in one window. –  Loïc Wolff Nov 8 '09 at 12:40

Lawrence link is the answer :

Select the option to open in new tabs from Preferences -> General


The most important part :

defaults write TargetedClicksCreateTabs -bool true

With both options, when I try open they both open in the same window in two different tabs.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.