Created
March 3, 2015 10:34
-
-
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.
This file contains 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
#! /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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that this relies on the fswatch project. It can be conveniently installed via brew:
brew install fswatch
.