How to Take a Screenshot from Mac Terminal (Screencapture)

Take a Screenshot from Mac Terminal

Want to automate or script taking screenshots on a Mac? Need to take a screenshot but don’t want to use the usual keyboard shortcuts and the screenshot app? Wondering whether you can make screenshots from the command line? Find out here how to take a screenshot from Mac Terminal using “screencapture” ⤓.

First, a Leiden Jar Discharges

Wilhelm Eduard Weber and Rudolf Kohlrausch, both physicists, discharged Leiden jars (electrostatic energy from early batteries) in 1856. When they measured the same current produced with electrodynamic energy (probably from a dynamo), they found a fixed ratio, and they called it ‘C’.

Weber’s constant C became a different (but naturally and importantly related) number, lost its upper case, and you know it today as c, the speed of light.

Now, I’m afraid the question why C and c are called C and c will have to wait for another time. Let’s turn to c, for now, the command line and compare times capturing screenshots with it and using a Mac’s graphical user interface:

How to Take a Screenshot from Mac Terminal Using Screencapture

Part of the Screen or a Window

Time needed: 3 minutes

To take a screenshot of a Mac’s full screen, window or selection from a Terminal command prompt using “screencapture”:

  1. Type screencapture -iP in Terminal.

    Here’s what you get: This will begin taking a screenshot in interactive mode (-i), which lets you choose a region or window to capture and opens the screenshot in Preview for saving or copying (-p).
    It doesn’t have to be that way: See below for other ways you can use screencapture.

  2. Press Enter.

    “Screen Recording”: macOS will alert you to Terminal’s missing credentials if it is not set up to access screen and audio for recording; see below for adding that permission.

  3. Use the mouse to pick the region of the screen you want to capture.

    Window: Press Space and click a window to take a screenshot of that window.

  4. Save the screenshot from Preview.

    As you like it: Preview lets you save in many an image file format.
    Their word: You can find information on screencapture in its man page.

Captured green text on black — and beyond?

Buy La De Du a tea

Tips help fuel these email and tech how-tos.

The Full Screen (With or Without Delay)

To capture the whole screen using screencapture in Terminal:

  • Type screencapture <filename> to capture the full screen immediately.
  • Use screencapture -T <seconds> <filename> to take a screenshot after a delay of <seconds> seconds.
    Filename: Replace <filename> with the name of the file where you’s like to save the screenshot (including a file extension); you can also use -P to open the screenshot in Preview, of course, or copy it to the clipboard (see below).

Allow Screencapture to Access the Screen

To allow Terminal (and screencapture) to record the screen on a Mac:

  1. Open System Settings.
  2. Go to the Privacy & Security category.
  3. Select Screen & System Audio Recording.
  4. Enable Terminal under Screen Recording & System Audio.
    No “Terminal”: If the Terminal app is not in the list, click + and open Terminal in the /Applications/Utilities folder.
    Allow Terminal and screencapture to take screenshots on a Mac

Take a Mac Screenshot without Drop Shadow

To make a screenshot of a window on a Mac without including the drop shadow:

  1. Run screencapture -ioP in Terminal.
    Here’s why: The -o option makes screencapture take screenshots without including shadows.
    Options: You can combine -o with other options, of course, to save directly to a file, for example; see below.
  2. Press Space.
  3. Click the window you want to capture as a screenshot without shadow.
  4. Save the image as desired from Preview.

More Screencapture Options for Taking Screenshots from Mac Terminal

Use the following general options:

  • Copy the screenshot to the clipboard.
    -c
  • Include the mouse cursor in the screenshot for full-screen pictures.
    -C
  • Capture windows without their drop shadow.
    -o
  • Choose the screen to capture, 1 for the primary screen, 2 for the secondary etc.:
    -D <screen number>
  • Choose the file format for the screenshot between jpg, pdf, tiff, heic or png (the default).
    -t <format>

How to Take a Screenshot from Mac Terminal Using Screencapture: Examples

CommandAction
screencapture ~/Downloads/screenshot.pngSave full screen to ~/Downloads/screenshot.png
screencapture -iPInteractive selection, screenshot opens in Preview
screencapture -T 5 -t heic screenshot.heicScreenshot after 5 seconds, saves to HEIC
screencapture -icInteractive selection, copy to clipboard
screencapture -C screenshot.pngInclude cursor in screenshot
screencapture -o window.pngWindow without drop shadow
screencapture -D 2 secondary.pngCapture secondary display

How to Take a Screenshot from Mac Terminal Using Screencapture: FAQ

My screenshots are blank and I get the error “could not create image from rect”; what gives?

This error typically appears when Terminal and screencapture cannot access graphics data.

Do enable Terminal for Screen Recording & System Audio in System Settings; see above.

(Tested with macOS Tahoe 26.0–26.5, Sequoia 15.1–15.4 and Sonoma 14.2–14.5; first published January 2024, last updated May 2026)

Home » Mac Tips and Resources » How to Take a Screenshot from Mac Terminal (Screencapture)