Search code examples
applescriptosascript

How to preview file contents from command line, instead of Finder.app


From a command-line in a terminal, is there any way to bring up the preview file contents screen that can be seen in Finder.app when pressing the spacebar -- without bringing Finder.app to the foreground with focus (i.e., keep Finder.app back-grounded). If so, can anyone please share with me the contents of an applescript (e.g., osascript) that will accomplish that goal.


Solution

  • From AppleScript:

    set myFile to "/Users/lawlist/Desktop/test.jpg"
    do shell script "qlmanage -p " & quoted form of myFile & ">& /dev/null"