Automatically Copy macOS Screenshot Path for Claude Code

Boon aka Hwee-Boon Yar October 16, 2025
Source

Claude Code is my tool of choice for AI coding. I wrote about using Claude Code here.

Claude Code as well as several silent agentic CLI tools support dropping in an image file or pasting an image filepath. It's very useful for referring to screenshots. I used it all the time, but it's tedious to type and then:

  1. cmd+shift+4 and drag to make a screenshot
  2. F11 (macOS Exposé) to reveal desktop
  3. Drag the image file from the desktop
  4. F11 to end Exposé
  5. Drag the image file and drop onto Claude Code

Step 3 has gotten worse with macOS Tahoe where the desktop seem to take longer to refresh so I made a fish function so that the process becomes:

  1. cmd+shift+4 and drag to make a screenshot
  2. Paste the image file path into Claude Code

No waiting for macOS Tahoe, and much, much faster.

The short answer: Claude Code's terminal UI can work with a screenshot path, so I copy the path automatically and paste it into the CLI.

Here's the fish function. Just keep it running in a terminal window:

#Run by itself and keep running to watch for new screenshots and copy to clipboard. Useful for pasting them into Claude Code instead of dragging and dropping files function watchscreenshots fswatch -0 --monitor fsevents_monitor --latency 0.1
--event Created --event Renamed --event Updated ~/Desktop | while read -z path test -f "$path"; or continue set base (basename -- "$path")

# Match macOS-style screenshots only
if string match -q "Screenshot * at *.*.png" "$base"
  # Wait briefly for the file to finish writing
  #sleep 0.2
  printf "%s" "$path" | pbcopy
  terminal-notifier -title "Screenshot" -message "Path copied: $base" -group "screenshotpaths" >/dev/null 2>&1
  sleep 2
  # Detach from stdin/stdout so terminal-notifier doesn't hang when run inside a pipeline (e.g. fswatch | while read ...).
  # </dev/null prevents it from waiting for input, >/dev/null 2>&1 silences output/errors.
  #terminal-notifier -remove "screenshotpaths"
  terminal-notifier -remove screenshotpaths </dev/null >/dev/null 2>&1
end

end end

Update: I've since turned this into a proper CLI tool called shotpath — a single Swift binary with no dependencies. Install via Homebrew and run it as a background service.

brew tap hboon/tap brew install shotpath brew services start hboon/tap/shotpath

The fish function below is still useful if you want to see exactly what is happening. For daily use, I use shotpath now because it does not need a terminal window sitting around just to watch the Desktop.

WHY PASTE THE FILE PATH

Dragging a screenshot into a terminal workflow is awkward. Pasting the path keeps me in the keyboard flow:

/Users/hboon/Desktop/Screenshot 2026-05-20 at 10.31.42 AM.png

I can take a screenshot, paste the path into Claude Code, and ask it to inspect the UI, error, email, or terminal output in that image.

This also works better with multiple coding agents. If I am in tmux, I can paste the same screenshot path into Claude Code, Droid, or Codex without leaving the pane. The file stays on disk, so I can reuse the path later in the thread if the agent needs to compare the same UI state against a later screenshot.

Have fun!

Discussion in the ATmosphere

Loading comments...