I have a node project where I output a filename to stdout in the terminal with process.stdout.write(filename + '\n');. How can I pipe this output to the open command or some other command to open the file (an image in this case) with the default image viewer?
1 Answer
As Mark Setchell points out in the comments, you will need to pass -a <appname> to open the file with a specific application.
However, you will need to pipe the file to stdout instead of just the filename, fore example like this:
var fs = require('fs');
fs.createReadStream("./test.jpg").pipe(process.stdout);
and then of yourse node yourNodeFile.js | open -f -a Preview.app
node some_node_file.js | open -fAs far as I knowopenwaits filename as an argument, so it's just bash issue.open -fsimply opens the output text (a.k.a. the file name) in the default text editor. It doesn't open the image file with the default image viewer.-a <appname>. I guess you needPreviewfor images.