Open files from command line on Mac

I tend to use User Interfaces as much as possible because i like them and i like to built them. Nevertheless i am finding myself more and more working on the command line.

Since i never start a project again without build-tools like grunt or gulp or package managers like bower or composer and favoriting a vagrant i spent a lot of time during the development on the terminal.

Btw. i prefer iterm2 as my terminal replacment with, zsh as my shell configured with oh my zsh and the agnoster theme with Sauce Code Powerline font.

my terminal

In some cases you just want to open a file in the current directory e.g. previewing an image or open a HTML file in the browser. Just type

open myimage.png

to open a file with the registered default program for this filetype.

You can also specify the program you want to use for opening the file. In case Chrome is your default browser but you want to open a HTML file in Safari type

open -a Safari index.html

Opening an URL is as simple


To open a directory in Finder type

open .

to open the current folder or specify the folder you want to open

open images/icons/svg/

Opening a file from the command line is as we can see as simple as it should be.

Leave a Reply

Your email address will not be published. Required fields are marked *