Instantly share code, notes, and snippets.

@jdp /cap.sh
Last active Jan 29, 2016

Embed
What would you like to do?
Upload screenshot to imagebin and copy URL to clipboard. OS X only
#!/usr/bin/env bash
set -e
declare fn
function cleanup {
rm "$fn"
}
trap cleanup EXIT
fn="$(mktemp -t cap).png"
screencapture -i "$fn"
mimetype=$(file --mime-type -b "$fn")
if [[ "$mimetype" == image/* ]]; then
if upload=$(curl http://imagebin.ca/upload.php -F file="@$fn" 2>/dev/null); then
echo "$upload" | grep '^url:' | sed 's/^url://' | pbcopy
afplay -v 2 /System/Library/Sounds/Glass.aiff &
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment