Notice: load_plugin_textdomain was called with an argument that is deprecated since version 2.7 with no alternative available. in /home/scott47/public_html/wordpress/wp-includes/functions.php on line 3844

Notice: register_sidebar was called incorrectly. No id was set in the arguments array for the "Sidebar 1" sidebar. Defaulting to "sidebar-1". Manually set the id to "sidebar-1" to silence this notice and keep existing sidebar content. Please see Debugging in WordPress for more information. (This message was added in version 4.2.0.) in /home/scott47/public_html/wordpress/wp-includes/functions.php on line 3897

Notice: load_plugin_textdomain was called with an argument that is deprecated since version 2.7 with no alternative available. in /home/scott47/public_html/wordpress/wp-includes/functions.php on line 3844
Scott Sims » Blog Archive » Managing browsers from the command line on OS X
Notice: get_currentuserinfo is deprecated since version 4.5! Use wp_get_current_user() instead. in /home/scott47/public_html/wordpress/wp-includes/functions.php on line 3658

Managing browsers from the command line on OS X

Have you ever wanted to open a url from the command line on OS X?  Turns out open can do many cool things like that.

open -a ‘google chrome’ ‘http://www.scottcsims.com’

open -a ‘firefox’ ‘http://www.scottcsims.com’

Sometimes a parallel Selenium run might get out of control and you need to close all your browsers, try this one from the command line:

killall firefox

Yes, I know killall is a very old Unix command, but I didn’t know that I could pass it an application name that a OS X has bound to an executable.

I like the -a and -e options for open.

Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b ] [-a ] [filenames] [--args arguments]
Help: Open opens files from a shell.
      By default, opens each file using the default application for that file.  
      If the file is in the form of a URL, the file will be opened as a URL.
Options: 
      -a                Opens with the specified application.
      -b                Opens with the specified application bundle identifier.
      -e                Opens with TextEdit.
      -t                Opens with default text editor.
      -f                Reads input from standard input and opens with TextEdit.
      -F  --fresh       Launches the app fresh, that is, without restoring windows. Saved persistent state is lost, excluding Untitled documents.
      -R, --reveal      Selects in the Finder instead of opening.
      -W, --wait-apps   Blocks until the used applications are closed (even if they were already running).
          --args        All remaining arguments are passed in argv to the application's main() function instead of opened.
      -n, --new         Open a new instance of the application even if one is already running.
      -j, --hide        Launches the app hidden.
      -g, --background  Does not bring the application to the foreground.
      -h, --header      Searches header file locations for headers matching the given filenames, and opens them.

One Comment

  1. […] Managing browsers from the command line on OS X is a bit of shell trickery I’d ashamed to admit I didn’t know. Well, the open bit at any rate. […]

Leave a Reply

*