How to Capture Custom Screenshots and Video Clips from the macOS Terminal Using screencapture

While macOS includes comprehensive graphical screen capture tools via the Cmd + Shift + 3, 4, and 5 keyboard shortcuts, power users, automated testing pipelines, and fleet administrators frequently need to capture screenshots programmatically. Whether generating automated UI documentation, capturing visual regression snapshots in Continuous Integration (CI) runners, or grabbing high-resolution desktop imagery from remote SSH sessions, invoking a graphical interface is often impractical. The built-in macOS command-line utility screencapture provides comprehensive, scriptable control over the window server’s display rendering pipeline directly from Terminal.

Basic Screenshot Syntax and Immediate Capture

The standard syntax for screencapture requires only an output file destination:

screencapture ~/Desktop/fullscreen.png

Executing this command captures all connected display monitors and writes the image file immediately to your Desktop in PNG format. You can customize the image format using the -t flag, specifying formats such as jpg, pdf, tiff, or heic:

screencapture -t jpg ~/Desktop/fullscreen.jpg

Capturing Silently Without Shutter Sounds

In automated scripts or quiet office environments, the traditional camera shutter sound can be disruptive. To capture screens completely silently, append the -x flag:

screencapture -x ~/Desktop/silent_capture.png

Interactive Selection and Window Capture

You can invoke macOS’s native interactive selection crosshairs directly from the command line:

  • Interactive Rectangle Selection: To launch the mouse selection crosshairs:
    screencapture -i ~/Desktop/selection.png
  • Single Window Capture: To capture an exact application window with clean transparency and shadows, combine -i with the -w flag:
    screencapture -i -w ~/Desktop/window_capture.png
    Your mouse cursor turns into a camera icon. Clicking on any open application window captures that exact window while cropping out background clutter.
  • Capturing Without Window Shadow: By default, window captures include Apple’s soft drop shadow. To produce a crisp, edge-to-edge window graphic without drop shadows:
    screencapture -i -w -o ~/Desktop/window_no_shadow.png

Routing Screenshots Directly to the Clipboard

If you wish to paste a screen grab into an email, Slack channel, or graphic editing software without cluttering your local filesystem with image files, route output directly to the macOS clipboard using the -c flag:

screencapture -c -i

The captured selection is stored in your active system clipboard, ready for instant Cmd + V pasting.

Recording Screen Video from the Command Line

In modern macOS versions, screencapture also functions as a lightweight screen video recorder using the -v flag:

screencapture -v ~/Desktop/screen_recording.mov

The command begins recording the primary display immediately, writing the stream to a QuickTime .mov container. Press Ctrl + C in the Terminal console to stop recording and finalise the video file cleanly on disk.

Managing Permissions and TCC Privacy Restrictions

Because screen capture captures sensitive desktop contents, macOS enforces strict Transparency, Consent, and Control (TCC) security policies. When executing screencapture from Terminal, iTerm2, or an automation runner, the initiating application must have Screen Recording permissions enabled under System Settings > Privacy & Security > Screen & System Audio Recording. If permissions are missing, screencapture outputs an empty desktop wallpaper graphic devoid of application windows.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.