Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Safari command line args?

Is there a webpage with Safari command line args listed does anyone know? (Does Safari in fact have any!?)


In 'nix environments you can usually list them with something along the lines of 'safari --help' (or whatever the safari program name is) - I don't unfortunately have a Mac in front of me, if someone could give this a go it would be appreciated 🙂

Safari-OTHER, Mac OS X (10.5.8)

Posted on Jun 11, 2011 1:31 PM

Reply
Question marked as Best reply

Posted on Jun 11, 2011 1:35 PM

Does Safari in fact have any!?


No. Aqua applications don't normally start from the shell.

3 replies

Apr 28, 2015 11:54 AM in response to SnowflakesAndStars

open -a safari http://www.apple.com --args h=300 w=400

The example you gave of the command and its arguments are actually arguments of the command /usr/bin/open .


"open" is the command

"-a safari" means use the application "safari" to open the URL (overriding default browser if different)

"http://www.apple.com" is the file, which, when formatted like a URL, are passed to the default web browser.

"--args h=300 w=400" are all technically still arguments of the /usr/bin/open command; however everything after "--args" is blindly passed on to the browser on its command line, so it is completely up to the browser to either interpret or not interpret those arguments.


Perhaps the real information you are looking for is what type of variables you can pass safari (so far all we know is "h" and "w", which I presume work to define the size of the browser window by height and width. I have posted the man page for "open" below.


$ man open


OPEN(1) BSD General Commands Manual OPEN(1)



NAME

open -- open files and directories



SYNOPSIS

open [-e] [-t] [-f] [-F] [-W] [-R] [-n] [-g] [-h] [-b bundle_identifier]

[-a application] file ... [--args arg1 ...]



DESCRIPTION

The open command opens a file (or a directory or URL), just as if you had

double-clicked the file's icon. If no application name is specified, the

default application as determined via LaunchServices is used to open the

specified files.



If the file is in the form of a URL, the file will be opened as a URL.



You can specify one or more file names (or pathnames), which are inter-

preted relative to the shell or Terminal window's current working direc-

tory. For example, the following command would open all Word files in the

current working directory:



open *.doc



Opened applications inherit environment variables just as if you had

launched the application directly through its full path. This behavior

was also present in Tiger.



The options are as follows:



-a application

Specifies the application to use for opening the file



-b bundle_indentifier

Specifies the bundle identifier for the application to use when open-

ing the file



-e Causes the file to be opened with /Applications/TextEdit



-t Causes the file to be opened with the default text editor, as deter-

mined via LaunchServices



-f Reads input from standard input and opens the results in the default

text editor. End input by sending EOF character (type Control-D).

Also useful for piping output to open and having it open in the

default text editor.



-F Opens the application "fresh," that is, without restoring windows.

Saved persistent state is lost, except for Untitled documents.



-W Causes open to wait until the applications it opens (or that were

already open) have exited. Use with the -n flag to allow open to

function as an appropriate app for the $EDITOR environment variable.



-R Reveals the file(s) in the Finder instead of opening them.



-n Open a new instance of the application(s) even if one is already run-

ning.



-g Do not bring the application to the foreground.



-h Searches header locations for a header whose name matches the given

string and then opens it. Pass a full header name (such as NSView.h)

for increased performance.



--args

All remaining arguments are passed to the opened application in the

argv parameter to main(). These arguments are not opened or inter-

preted by the open tool.



EXAMPLES

"open '/Volumes/Macintosh HD/foo.txt'" opens the document in the default

application for its type (as determined by LaunchServices).



"open '/Volumes/Macintosh HD/Applications/'" opens that directory in the

Finder.



"open -a /Applications/TextEdit.app '/Volumes/Macintosh HD/foo.txt'"

opens the document in the application specified (in this case, TextEdit).



"open -b com.apple.TextEdit '/Volumes/Macintosh HD/foo.txt'" opens the

document in the application specified (in this case, TextEdit).



"open -e '/Volumes/Macintosh HD/foo.txt'" opens the document in TextEdit.



"ls | open -f" writes the output of the 'ls' command to a file in /tmp

and opens the file in the default text editor (as determined by Launch-

Services).



"open http://www.apple.com/" opens the URL in the default browser.



"open 'file://localhost/Volumes/Macintosh HD/foo.txt'" opens the document

in the default application for its type (as determined by LaunchSer-

vices).



"open 'file://localhost/Volumes/Macintosh HD/Applications/'" opens that

directory in the Finder.



"open -h NSView" lists headers whose names contain NSView and allows you

to choose which ones to open.



"open -a Xcode -h NSString.h" quickly opens /System/Library/Frame-

works/Foundation.framework/Headers/NSString.h in Xcode.



HISTORY

First appeared in NextStep.



Mac OS X February 10, 2004 Mac OS X

Safari command line args?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.