October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Automation

How to Take Screenshots with `screencapture` in Bash on macOS

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On macOS, take a full-screen screenshot from Bash with screencapture "$HOME/Desktop/shot.png". The same utility can select a region or window, capture a fixed rectangle, target the main monitor, delay a capture, copy it to the clipboard, and choose PNG, JPEG, TIFF or PDF output. The examples below show each mode and the shell patterns needed for repeatable captures.

Prerequisites and the basic command

screencapture is built into macOS; run it from Terminal or any Bash script. Give the command a destination path. PNG is the documented default format.

screencapture "$HOME/Desktop/shot.png"

Quote paths so spaces and shell metacharacters in folder or file names do not break the command. A successful run writes the image and returns control to the shell. If a file already exists, test your macOS version’s behavior before relying on overwrite semantics in an automated job.

Choose what to capture

Entire current display

#!/usr/bin/env bash
set -euo pipefail
out="$HOME/Desktop/full-$(date +%Y%m%d-%H%M%S).png"
screencapture "$out"
printf 'Saved %sn' "$out"

The timestamp prevents repeated runs from using the same name. It also makes a useful shell-script pattern for periodic evidence or test captures.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Main monitor only

screencapture -m "$HOME/Desktop/main-monitor.png"

-m restricts a non-interactive capture to the main monitor. Multi-display arrangements differ, so verify which display macOS considers primary.

Interactive region or window

# Drag a rectangle, or use the onscreen selection controls
screencapture -i "$HOME/Desktop/selection.png"

# Window-oriented modes
screencapture -w "$HOME/Desktop/window.png"
screencapture -W "$HOME/Desktop/window-focused.png"

-i starts interactive selection. The -w and -W switches select window-oriented modes; the exact interaction can vary by macOS release, so try them manually before embedding one in unattended automation.

Fixed rectangle

# x,y,width,height
screencapture -R 100,100,800,600 "$HOME/Desktop/rectangle.png"

The rectangle is measured in screen coordinates. Display scaling, menu bars, and multiple monitors affect those coordinates. Confirm the origin and dimensions on the target Mac rather than assuming they match another machine.

Control format, timing, sound and cursor

Image formats

Use -t followed by a format listed by the manual: png, jpg, tiff or pdf.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
screencapture -t jpg "$HOME/Desktop/photo.jpg"
screencapture -t tiff "$HOME/Desktop/print.tiff"
screencapture -t pdf "$HOME/Desktop/page.pdf"

Keep the filename extension consistent with the selected type. PNG is a practical default for interface text; JPEG is smaller for photographic content but introduces lossy compression.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Delay the capture

# Wait five seconds before capturing
screencapture -T 5 "$HOME/Desktop/delayed.png"

# Delay and select JPEG explicitly
screencapture -T 5 -t jpg "$HOME/Desktop/delayed.jpg"

-T takes a delay in seconds. A delay lets you open a menu, move a window, or prepare a demonstration without racing the command.

Suppress sound or include the pointer

screencapture -x "$HOME/Desktop/silent.png"
screencapture -C "$HOME/Desktop/with-cursor.png"
screencapture -C -x "$HOME/Desktop/with-cursor-silent.png"

-x suppresses the capture sound. -C includes the cursor. These switches can be combined with display, region, format, and delay options.

Copy directly to the clipboard

screencapture -c

-c writes the capture to the clipboard instead of a file. Paste it into an image editor, message, or document. Because no destination path is supplied, this is best for interactive use rather than archival scripts.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Reusable Bash scripts

Validate a destination and create a dated capture

#!/usr/bin/env bash
set -euo pipefail

folder="${1:-$HOME/Desktop/screenshots}"
mkdir -p -- "$folder"
out="$folder/shot-$(date +%Y%m%d-%H%M%S).png"

screencapture -x -- "$out"
printf 'Screenshot saved to %sn' "$out"

This script creates the destination directory, uses a unique timestamped name, and silences the shutter sound. Invoke it as ./capture.sh or pass another folder as the first argument. The -- protects paths beginning with a hyphen where supported; if a particular macOS release rejects it, remove that separator and keep the path quoted.

Capture repeatedly at an interval

#!/usr/bin/env bash
set -euo pipefail

folder="$HOME/Desktop/series"
mkdir -p -- "$folder"
interval=10
count=6

for ((i=1; i<=count; i++)); do
  out="$folder/frame-$(printf '%03d' "$i")-$(date +%Y%m%d-%H%M%S).png"
  screencapture -x -- "$out"
  printf 'Wrote %sn' "$out"
  (( i < count )) && sleep "$interval"
done

This takes six captures, ten seconds apart. For a long-running monitor, replace count with a controlled stop condition and add log rotation so the directory cannot grow without limit. Avoid capturing sensitive information and confirm that the user session remains unlocked; a locked or unavailable display can produce an unusable result.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Combine options for common jobs

Goal Command What it changes
Quiet main-monitor PNG screencapture -m -x "$HOME/Desktop/main.png" Main display, no sound
Interactive selection screencapture -i "$HOME/Desktop/selection.png" User chooses a region or target
Known screen coordinates screencapture -R 100,100,800,600 "$HOME/Desktop/rect.png" Repeatable rectangle
Delayed JPEG screencapture -T 5 -t jpg "$HOME/Desktop/delayed.jpg" Five-second delay and JPEG output
Clipboard image screencapture -c No file; image goes to clipboard
Pointer visible screencapture -C "$HOME/Desktop/pointer.png" Includes cursor

Permissions, display behavior and reliability

macOS privacy controls can prevent screen capture. If the command reports a permission failure or produces a blank image, open System Settings → Privacy & Security → Screen Recording, enable access for the application launching the command (for example, Terminal or your script runner), then restart that application if macOS requests it. Organization-managed Macs may enforce a policy that you cannot change.

Test interactive commands in the same display arrangement used in production. Coordinates can move when a laptop is docked, a monitor is rearranged, or display scaling changes. A fixed rectangle is deterministic only when those conditions remain stable. For unattended jobs, prefer a known destination, explicit format, delay where needed, and error checking with set -euo pipefail. Check that the output file exists and has nonzero size before handing it to another process:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
if [[ ! -s "$out" ]]; then
  printf 'Capture failed or produced an empty file: %sn' "$out" >&2
  exit 1
fi

Troubleshooting

“command not found”

screencapture is a macOS utility. It will not be available on Linux or Windows, and a nonstandard PATH can hide system tools. Confirm you are running macOS and try /usr/sbin/screencapture in a diagnostic shell.

The output is blank, black or missing

  • Grant Screen Recording permission to the launching app, then restart it.
  • Ensure the target display is awake and an interactive user session is present.
  • Remove an experimental rectangle and test a full-screen capture to distinguish coordinate errors from permission problems.
  • Check the file path, parent directory, and available disk space.

The wrong monitor or area is captured

Use -m for the main monitor, or recalibrate -R x,y,width,height after changing display arrangement or scaling. Use -i when a human can select the area safely.

The window selection does not behave as expected

Try both -w and -W, and test on the macOS release used by your script. Window-focused interaction is inherently more sensitive to the current desktop state than a fixed rectangle.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

The file type and extension disagree

Set the format explicitly with -t and use the matching extension. Downstream tools often infer type from the extension, even when the file bytes are valid.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

For a website screenshot rather than the physical Mac display, ScreenshotNeo returns a PNG, JPEG, WebP or PDF from one request. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and whether it was billed. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.

cURL (see the ScreenshotNeo API documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

The API also supports full-page lazy-image loading, CSS-selector element capture, dark mode, 12 device presets or any viewport, retina scale, PDF paper settings and page ranges, custom CSS and JavaScript, clicks before capture, hidden selectors, waits for selectors/delays/network idle, request and resource blocking, custom headers/cookies/user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs work as well.

Plans include 1,000 free shots each month with no card; paid plans start at $5 for 3,000 shots. Higher plans are Starter $5/3,000, Growth $15/15,000, Pro $39/60,000, Scale $99/250,000 and Business $249/1,000,000; yearly billing gives two months free, and every feature is included on every plan. Start with the free ScreenshotNeo account.

FAQ

Can screencapture record video?

The utility documents video-recording flags as well as still-image capture, but this article covers still screenshots. Consult the local manual with man screencapture for the recording switches available on your macOS release.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which option is safest for an automated script?

A full-display or main-monitor capture with an explicit destination, format, timestamped filename and permission check has fewer environmental dependencies than interactive window selection.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Can I capture a website without opening a Mac desktop session?

No. screencapture captures the macOS display. Use a website screenshot API such as ScreenshotNeo when the input is a URL and the job should run independently of a logged-in desktop.

Frequently Asked Questions

Can screencapture record video?

The utility documents video-recording flags as well as still-image capture, but this article covers still screenshots. Consult the local manual with man screencapture for the recording switches available on your macOS release.

Which option is safest for an automated script?

A full-display or main-monitor capture with an explicit destination, format, timestamped filename and permission check has fewer environmental dependencies than interactive window selection.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I capture a website without opening a Mac desktop session?

No. screencapture captures the macOS display. Use a website screenshot API such as ScreenshotNeo when the input is a URL and the job should run independently of a logged-in desktop.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.