Created
December 12, 2025 10:58
-
-
Save hboon/695534f0b9f19567f57c53db3453f786 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment