How to start preview from command line and get back to the terminal when I press ESC

consoleitermpreview

I do want to add file view support for media files to midnight commander and I something that can be called form the command line that would start preview but that will return to my terminal when I press ESC.

Note: I already found half of the solution here http://hints.macworld.com/article.php?story=20040514133013713 – the only problem is that it doesn't close Preview with Escape.

So there are two possible solutions:

  • Find a way to map ESC to Cmd+Q only for Preview (I want a command line install solution)
  • Find a way to open Preview in the special mode used by the Finder (the tiny preview), which by default is closed with a simple Esc.

Best Answer

You could use qlmanage instead.

/usr/bin/qlmanage -p file1.pdf file2.pdf file3.pdf

This will open the files in quicklook.

You can then use escape or the space bar which will close the quicklook previews and be back in terminal since it is the active app.