Capture images from the screen and save them to a file or the clipboard from the command line in Mac OS X.

# To take a screenshot and save it to a file:
screencapture <path/to/file.png>

# To take a screenshot including the mouse cursor:
screencapture -C <path/to/file.png>

# To take a screenshot and open it in Preview, instead of saving:
screencapture -P

# To take a screenshot of a selected rectangular area:
screencapture -i <path/to/file.png>

# To take a screenshot after a delay:
screencapture -T <seconds> <path/to/file.png>

# To make a screen recording and save it to a file:
screencapture -v <path/to/file.mp4>

# ---

# To take a screen shot (default save path `~/`)
$ screencapture example.png

# To take a screen shot without the shadow
$ screencapture -oi example.png

# To capture a screen shot to the clipboard
$ screencapture -c

# To take screen shot after a 10-second delay
$ screencapture -T 10 example.png

# To take screen shot and save it as pdf
$ screencapture -t pdf example.pdf

# To quiet the audible snapshot sound
$ screencapture -x example.png

# To send the screen shot directly to mail
$ screencapture -M example.png

# To take screen shot and open in Preview
$ screencapture -P example.png

# Change the screen capture file format
$ defaults write com.apple.screencapture type png \
    && killall SystemUIServer