Filed under: How-tos, Terminal Tips
Terminal Tip: 6 easy ways to capture your screen
OS X's built in screencapture command provides a simple command-line utility to snap images of your desktop. It offers quite a few options and many of them do not quite work as advertised. Even the manual page admits that screencapture is "not very well documented to date".
To make it easier for you to jump in and get started with screencapture, here are six convenient already-tested variations that you can copy, paste and use. Consider adding these capture methods to shell scripts, to system calls from AppleScript or just running them directly from the command line as needed.
1. Capture your primary screen as a (default) png file.
% screencapture ~/Desktop/screencap.png
2. Capture your primary screen as a jpeg (-tjpeg), including the cursor (-C)% screencapture -C -tjpeg ~/Desktop/mycapture.jpg
3. Wait for five seconds before capturing the screen.% sleep 5; say "ready"; screencapture ~/Desktop/mycapture.png
4. Interactively (-i) select (-s) an area of your screen with the mouse.% screencapture -i -s -tjpeg ~/Desktop/mycapture.jpg
5. Interactively (-i) select a window with the mouse. When the crosshairs appear after issuing this command, press the space bar then select a window with the camera.% screencapture -i -tjpeg ~/Desktop/mywindow.jpg
6. Select an area of your screen and copy it to the clipboard (-c) rather than a file.% screencapture -i -s -c

![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 1)
superjeff said 11:21AM on 5-17-2007
So how did you capture THAT screen shot?
Reply
Erica Sadun said 11:21AM on 5-17-2007
Used option #5 to set up the screen and SnapzPro to shoot the screen shot shooting.
Reply
tim said 11:48AM on 5-17-2007
Why not just use "Grab?" It's already designed to do this and there are no command lines necessary. I've never understood why people want to do things the more complicated/nerdy way.
Reply
Erica Sadun said 11:48AM on 5-17-2007
Tim: The command line better lends itself to automation.
Reply
James Gregory said 11:53AM on 5-17-2007
You can do the same thing using keyboard shortcuts.
Cmd + Shift + 3 = Take screenshot of whole screen
Cmd + Shift + 4 = Draw an area to capture
Cmd + Shift + 4, then space = Capture a window.
Reply
Martin Sketchley said 1:09PM on 5-17-2007
I use a very useful widget called Screenshot Plus. It's great.
Reply
Justin said 2:21PM on 5-17-2007
ditto on the keyboard shortcuts, why even bother with anything else...you can't really simplify it much more.
Reply
sine_nomine said 2:41PM on 5-17-2007
Hmm, the png it created couldn't be opened by Preview or Photoshop, and it didn't like the -tjpeg option. Maybe a Jaguar thing? (Yes, I'm still using Jaguar...)
It's odd, I've been having trouble getting a screen capture lately using everything from Grab to Snap 'n Drag - everything comes out garbled and there are often features mashed in like parts of windows that aren't even open. I was kind of hoping this would be an alternative that would work, but alas no.
Reply
VanillaSpice said 10:41PM on 5-17-2007
james, justin - key commands aren't useful in scripting, and this command also allows you to select the output format.
Reply
Cary said 1:11PM on 5-19-2007
Can I capture a window with a clean shadow? I mean, only the transparent shadow itself, but NOT the background content under the shadow. This way when I post this image on a web page with any background color, the shadow always matches nicely.
Reply