Here is an AppleScript that should help you. Open AppleScript Editor and save this as a script. I have modified the source that I found here to support taking arguments on the command line.
Use it like this:
osascript new_window.scpt http://www.google.com http://www.stackoverflow.com
Of course, replace the URLs above with your own URLs.
new_window.scpt
on run argv
tell application "Safari"
if (count argv) = 0 then
-- If you dont want to open a new window for an empty list, replace the
-- following line with just "return"
set {first_url, rest_urls} to {"", {}}
else
-- `item 1 of ...` gets the first item of a list, `rest of ...` gets
-- everything after the first item of a list. We treat the two
-- differently because the first item must be placed in a new window, but
-- everything else must be placed in a new tab.
set {first_url, rest_urls} to {item 1 of argv, the rest of argv}
end if
make new document at end of documents with properties {URL:first_url}
tell window 1
repeat with the_url in rest_urls
make new tab at end of tabs with properties {URL:the_url}
end repeat
end tell
activate
end tell
end run
You could even create an alias for this in Terminal and be able to use it easier. I would add the following to ~/.bash_profile
:
alias newwindow='osascript /path/to/new_window.scpt'
Call newwindow
whatever you want. Save .bash_profile
and restart Terminal for it to work.
In case anyone is looking for a similar solution for Google Chrome, here is a different take on the same idea.
chrome_new_window.scpt
on run argv
tell application "Google Chrome"
if (count argv) = 0 then
make new window
else
tell (make new window)
set URL of active tab to item 1 of argv
repeat with the_url in the rest of argv
open location the_url
end repeat
end tell
end if
set active tab index of first window to 1
activate
end tell
end run
EDIT: Making my answer better by offering a keyboard shortcut method since my question found a solution back in the day. for even quicker safari extension disabling in or out of private mode.
ORIGINAL: A much easier way to perform this action is to enable the Develop Menu in Safari Preferences -> Advanced -> At the bottom you can check this to have a Develop menu in your menu bar for safari. Here you can select from the dropdown "Disable Extensions" which will disable them completely for both private and non-private windows but the activation and disabling of the add-ons is extremely quick and hassle free.
Making private window/tabs default to having extensions disable isn't an option in any Safari settings sadly. However this is an easy one click solution to your problem.
Again, the steps are as follows:
Safari -> Preferences -> Advanced Tab -> check "Show Develop menu in menu bar"
Now you can click the Develop dropdown and click "Disable Extensions" as well as other options such as javascript, images, styles, and more!
This works with Safari 9.0 - 11.0
Best Answer
Note: This is only one possible method. It works by simulating the pressing of ShiftCmdN. You can also simulate the pressing of the menu item, but the script is longer.
Create a new file, and paste in these contents:
Save it somewhere (here, I'll pretend it's called
myscript
).In Terminal, find the file and make it executable:
Simply run it to create a new private window in Safari
If you want to be able to use this script regardless of your current working directory, create an alias OR move it to
/usr/local/bin
.If you want an alias, use
You can add this line to
~/.bashrc
or~/.bash_profile
to automatically load this alias when you start Terminal.