Terminal 101: Taking screenshots through the command line
Posted 06/11/2012 at 3:59pm
| by Cory Bohon
Every Monday, we'll show you how to do something new and simple with Apple's built-in command line application. You don't need any fancy software, or a knowledge of coding to do any of these. All you need is a keyboard to type 'em out!
Snapping screenshots is a pretty easy task in OS X, but not all of the screenshot options are available to you right from the keyboard shortcuts. Through the Terminal, however, you can take timed screenshots, copy the screenshot to the clipboard, and even mute the annoying shutter snap sound. In addition, this method can be used with SSH to capture those hard-to-get screenshots remotely, like the Mac OS X login window.
Follow along, and we’ll show you how to do this and more with the screencapture command in Terminal.
Standard Screenshots

To take a standard, simple screenshot from the Terminal, open Terminal and type in the following command:
screencapture test.jpg
The screenshot will be stored in your home directory, or you can specify another path and filename in place of “test.jpg.”
Capturing a screenshot to the clipboard
You can also capture a screenshot to your Mac’s clipboard instead of outputting the image to a file by typing the following command instead:
screencapture -c
Taking Screenshots with a Timer

The above methods for taking a screenshot will instantly take the shot, meaning that the Terminal window will be in the way. With the timer method of capturing a screenshot, you will have time to hide the Terminal window and position other windows perfectly.
screencapture -T 10 timed.jpg
Using the upper-case “T” flag, we can specify an amount of time (in seconds) that we want the screencapture program to wait until snapping the image. Here, it will wait 10 seconds before saving the screenshot as “timed.png.”
Specifying a file type
There are many different file types that can be used when snapping a screenshot. The screencapture tool is able to export as png, PDF, tiff, jpg, and gif, using the following command and flag:
screencapture -t tiff myscreen.tiff
Notice the lower-case “t” and the file type after it, finally followed by the filename and extension.
Quieting the snap
Each time your Mac takes a screenshot, it makes an audible clicking sound. To keep this sound from firing when you’re taking a screenshot, use the -x flag to quiet it.
screencapture -x screen.jpg
Sending the Screenshot Directly to Mail

If you’re intending to email the screenshot to someone, why not save a step and use this command instead:
screencapture -M screen.jpg
After the screenshot has been taken, a new Mail message will be opened, and the screenshot will automatically be included as an attachment.
Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow this article's author, Cory Bohon on Twitter.