Opening files from a Terminal window

Here are some quick tips that are handy if you work in a Terminal window a lot (I know I do!). They show various ways to open files and folders right from the command line.

Opening a file

You can open a file using its associated application by typing:

open filename

For example, opening an image file with open usually displays it in Preview, while opening an HTML file displays it in your default Web browser.

Wildcards are allowed, so you can open all PNG files in the current folder with:

open *.png

You can also specify the application to use when opening the file by using the -a option:

open -a /Applications/Preview.app myimage.png

If you want to edit the file in TextEdit, use:

open -e filename

You can even open URLs:

open https://mac.elated.com/

Opening a folder

This trick also works on folders, in which case the folder opens as a new Finder window:

open foldername

For example, you can open the current folder in the Finder with:

open .

Previewing a file

If you’re running Leopard, you can even Quick Look a file using qlmanage, a debugging tool for the Quick Look Server:

qlmanage -p myimage.png >& /dev/null

(The >& /dev/null stops debug info being displayed in the Terminal window.)

Press Control-C when you’re done to close the Quick Look window.

As with open, you can Quick Look multiple files at once:

qlmanage -p *.png >& /dev/null

You can then use the arrows at the bottom of the Quick Look window to move between each file, or click the Index Sheet button to view thumbnails of all the files at once.

More info on qlmanage, including various ways to create snappy aliases for the command, can be found on the Macworld site and on this blog.

Enjoy! 🙂

Bookmark this post:

2 Responses to “Opening files from a Terminal window”

  1. Abriendo ficheros desde Terminal | Says:

    […] estas constantemente en Terminal, algunos trucos de cómo abrir ficheros directamente sin Finder […]

  2. talip Says:

    thanks a lot.