Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,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 1.50 / 5
  You rated: 4 / 5 (8 votes cast)
 
[7,049 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 whoever posted them. This site is not responsible for what they say.
Open data from a pipeline in any application
Authored by: elmimmo on Mar 20, '08 08:23:51AM

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 Mar 20, '08 05:35:32PM
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 Mar 20, '08 05:58:16PM

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 Mar 20, '08 10:33:07PM

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 Mar 24, '08 02:13:08PM
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 | # ]