Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

Open data from a pipeline in any application UNIX
The open(1) command (man page) provides a -f option, which open's own help says "Reads input from standard input and opens with TextEdit". But, in fact, you can load the data into nearly any application. Simply combine the -f flag with the -a flag:
  • curl 'http://example.com/encodingerror.html' | open -a 'Hex Fiend' -f
  • curl 'http://example.com/example.html' | open -a 'TextMate' -f
  • curl 'http://example.com/example.png' | open -a 'Preview' -f
  • curl 'http://example.com/example.m4v' | open -a 'QuickTime Player' -f
Of course, the source of the data doesn't have to be curl; it can be any command. Note that the last two examples aren't even textual data: one is an image, and the other is a video file. You aren't limited to text; any data will work. But there is a catch: open will save the file with a .txt extension, regardless of what kind of data it is (it doesn't look). This could confuse some applications that rely on the filename extension to determine what type of document to open it as. Preview works, but I wouldn't count on any other applications without testing them first.

This hint works in 10.4, and should also work in 10.5. I don't know whether it works in any earlier versions of Mac OS X.
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[3,803 views]  

Open data from a pipeline in any application | 5 comments | Create New Account
Click here to return to the 'Open data from a pipeline in any application' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Open data from a pipeline in any application
Authored by: elmimmo on Thu, Mar 20 2008 at 8:23AM PDT
Use the -e attribute for a shorthand for TextEdit.

For example:

ls | open -e -f

[ Reply to This | # ]
Open data from a pipeline in any application
Authored by: aqsalter on Thu, Mar 20 2008 at 5:35PM PDT
I use a similar technique to download TextMate bundle updates...

E.g.
curl 'http://netcetera.org/cgi-bin/tmbundles.cgi?bundle=ActionScript' | sudo bash

You can browse bundles here:
http://netcetera.org/cgi-bin/tmbundles.cgi

[ Reply to This | # ]
Open data from a pipeline in any application
Authored by: wgscott on Thu, Mar 20 2008 at 5:58PM PDT
Finally a way to pipe into Preview.app.

Thank you!!!

[ Reply to This | # ]
Open data from a pipeline in any application
Authored by: saklad on Thu, Mar 20 2008 at 10:33PM PDT
Is there any way to use this to place a Keynote presentation into the background effect on iChat effectively giving you the ability to have you chromakeyed in front of the slide?

[ Reply to This | # ]
TextMate's 'mate' command-line
Authored by: dzurn on Mon, Mar 24 2008 at 2:13PM PDT
You can skip the 'open' line if you have TextMate's mate command installed:

diff ~/Documents/oldDir ~/Documents/newDir | sort | mate

---
Madness takes its toll.
Please have exact change.

[ Reply to This | # ]