Skip to content

Instantly share code, notes, and snippets.

@joostrijneveld
Created March 3, 2015 10:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joostrijneveld/f3c7a552a7d0344b04ca to your computer and use it in GitHub Desktop.
Save joostrijneveld/f3c7a552a7d0344b04ca to your computer and use it in GitHub Desktop.
Shell script that watches the desktop for screenshots (OSX default format) and then copies them to a remote using scp, leaving the URL available on the clipboard.
#! /bin/bash
# change the paths on line 9 and 10 to match your specific configuration
/usr/local/bin/fswatch -0 ~/Desktop | while read -d "" event; \
do \
if [[ ${event} == ~/Desktop/Screen* ]] && [[ -e ${event} ]]; then
newname=`cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | head -c 16`
scp "${event}" example.com:/var/www/files/screenshots/$newname.png > /dev/null
echo -n "http://files.example.com/screenshots/$newname.png" | pbcopy
fi;
done
@joostrijneveld
Copy link
Author

Note that this relies on the fswatch project. It can be conveniently installed via brew: brew install fswatch.

@rxw1
Copy link

rxw1 commented Mar 15, 2015

Thanks! See my fork for a variation of this. Screw CloudApp!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment