Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: Use Quick Look from the command line UNIX
For all you Leopard users out there, here's a handy tip on how to use Quick Look from the command line. Leopard ships with a command called qlmanage. The -p option shows a preview of the file passed to the command. In the terminal, type the following:
qlmanage -p thefile
As you'll see, it also generates a ton of text output when run. You can prevent this by creating the following shell script:
#!/bin/bash
qlmanage -p "$@" >& /dev/null &
The >& /dev/null prevents output from displaying, and the final & runs the process in the background so a new prompt displays in Terminal. Save this script as an executable file and store it somewhere in your PATH (I stored mine in a home bin folder used for custom-made scripts). I recommend naming it something short like ql.

When using the script, you can close the Quick Look window with the mouse (the conventional way), or close it in Terminal by getting the pid from the ps command and using kill pid#.

[robg adds: This hint originally appeared on the author's blog; check there for any udpates. I actually prefer the script without the last &, as you can then close the Quick Look window with a Control-C (but you cannot work on anything else in that same window until you do so, of course).]
    •    
  • Currently 2.83 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (6 votes cast)
 
[13,613 views]  

10.5: Use Quick Look from the command line | 6 comments | Create New Account
Click here to return to the '10.5: Use Quick Look from the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Use Quick Look from the command line
Authored by: ecbtln on Nov 16, '07 03:21:04PM

is there anyway to be able to use the command without ./ before it? I'm sure there is. The permissions for the file my ql are 700

-rwx------@ 1 username staff 44 Nov 16 17:54 ql

For example I see the author used the command ql without the ./ to use the command. Am I missing something obvious?



[ Reply to This | # ]
10.5: Use Quick Look from the command line
Authored by: wm on Nov 16, '07 04:29:39PM

Put it in one of the directories in your PATH, like the hint said. (/usr/bin/ should be one such directory.)



[ Reply to This | # ]
10.5: Use Quick Look from the command line
Authored by: drewag on Nov 16, '07 07:21:00PM

You have to add the folder in which the script is contained in, to your PATH. To do so open up ~/.bach_profile in any text editor and add the line:

export PATH="$PATH:/PATH/TO/Folder/"

so since my script is in a folder called "Scripts" in my home directory my bash_profile has"

export PATH="$PATH:~/Scripts/"



[ Reply to This | # ]
10.5: Use Quick Look from the command line
Authored by: drewag on Nov 16, '07 07:22:26PM

sorry...it is ~/bash_profile



[ Reply to This | # ]
10.5: Use Quick Look from the command line
Authored by: ecbtln on Nov 16, '07 09:52:06PM

does not exist so i created it, is that the right thing to do?



[ Reply to This | # ]
10.5: Use Quick Look from the command line
Authored by: ckromero on Apr 02, '12 09:00:29AM

Note that in 10.7 text output from using quickview is minimal, but invoking with '&' (bg job) doesn't seem to matter, both stall the terminal until you quit qlmanage.

In order to invoke Preview (which creates it's own process) I use:
----------------
#!/bin/bash
open -a Preview $1
----------------

and call as follows:
p someimage.png



[ Reply to This | # ]