Mac OS X Quick Tip – Taking screenshots from the command line

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

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

** 09/02/19 UPDATE: Thanks to nerdnotes.org for mentioning that the ‘-T’ (timed screenshot) option isn’t available in the Mac OS X 10.4.* (Tiger) version of this tool. Instead, you can use the command line sleep utility to take a timed screenshot: ’sleep 10; screencapture ~/Desktop/screenshot.png’.

 

Related posts:

  1. Taking Screenshots on the iPhone and in Mac OS X
  2. Mac OS X Quick Tip: Using Spotlight to search from the command line
  3. Changing the format of screenshots saved to your Desktop on Mac OS X
  4. Reusing commands with different arguments on a Bash command line
  5. UNIX Quick Tip: See the current UNIX Timestamp and other date formats on the command line
Twitter Digg Delicious Stumbleupon Technorati Facebook Email

Trackbacks/Pingbacks

  1. nerdnotes.org - 18 Feb 2009

    cmdline screenshots in OSX…

    Geekology describes a nice osx builtin command to create screen captures: screencapture. I wanted to create a screenshot of a mouse interaction. That requires some sort of a delay after initiating the capture. The “-T” option described faci…

Afrigator