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.

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

Have fun!