How to take screenshots from the command line on Mac OS X

05 Feb 2009

In addition to the default screenshot shortcut keys provided by Mac OS X, the built-in screencapture command line utility allows for a variety of screenshot options:

Capture the screen to the clipboard:

screencapture -c

Capture a selection or window (press spacebar to switch):

screencapture -i ~/Desktop/screenshot.png

Capture a window without its shadow (press spacebar after entering the command to enable Window Selection mode):

screencapture -io ~/Desktop/screenshot.png

Capture the screen and open the image in a new Mail message:

screencapture -M ~/Desktop/screenshot.png

Capture the screen and open the image in a Preview window:

screencapture -P ~/Desktop/screenshot.png

Capture the screen and save the image in the specified format (valid values are pdf, jpg, tiff, etc.):

screencapture -t png ~/Desktop/screenshot.png

Capture the screen after the specified amount of seconds have passed:

screencapture -T 10 ~/Desktop/screenshot.png

This option isn't available in Mac OS X 10.4.* (Tiger), on that version of OS X you should rather use the command line "sleep" utility:

sleep 10; screencapture ~/Desktop/screenshot.png

Capture the screen without playing the camera shutter sound:

screencapture -x ~/Desktop/screenshot.png

You can see all the screencapture parameters by running:

man screencapture

Keep in mind that these parameters can be combined, so you could, for instance, take a timed screenshot without the camera shutter sound:

screencapture -T 10 -x ~/Desktop/screenshot.png
Do you like this? Share it:

Copyright © Geekology 2012. All Rights Reserved.