Open Files from Command Line on OS X
I'm as much of a fan of application UIs as anyone else but I'm finding myself working more and more from the command line lately. Much of that is becoming obsessed with media manipulation but I'm forcing myself to use less UIs so that I can understand what's under the hood of my favorite utilities.
One common case for running any app is opening an existing file, like an HTML file in a browser or a document in Pages. To open a file on Mac OS X from the command line, type the following:
open portrait.png
The above does not specify an app to open the given file in -- the default app for that file type will be used. To open a file in a specific app, use the -a
argument:
open -a /Applications/Firefox.app portrait.png
You can also open a URL directly from the command line:
open https://davidwalsh.name/
You'd expect opening a file from command line to be easy and I'm happy to confirm to you that it is.
![Facebook Open Graph META Tags]()
It's no secret that Facebook has become a major traffic driver for all types of websites. Nowadays even large corporations steer consumers toward their Facebook pages instead of the corporate websites directly. And of course there are Facebook "Like" and "Recommend" widgets on every website. One...
![I’m an Impostor]()
This is the hardest thing I've ever had to write, much less admit to myself. I've written resignation letters from jobs I've loved, I've ended relationships, I've failed at a host of tasks, and let myself down in my life. All of those feelings were very...
![New York Times-Style Text Selection Widget Using MooTools or jQuery]()
Aaron Newton made a great request to me last week: why not make my MooTools Documentation Bookmarklet function more like the New York Time's text selection widget. NYT's text selection widget listens for text selection and presents the user with a "search" icon...
![:valid, :invalid, and :required CSS Pseudo Classes]()
Let's be honest, form validation with JavaScript can be a real bitch. On a real basic level, however, it's not that bad. HTML5 has jumped in to some extent, providing a few attributes to allow us to mark fields as required or only valid if matching...
I was just wondering how to do this, thanks!
When you use
-a
, you don’t need to write the path.…would do the same. :)
The
-a
handler is great when you want to open some program one doesn’t really know (eg remember) exactly where it is.Like:
// that one is in /System/Library/CoreServices