Automatically upload screenshots

I take a lot of screenshots and was looking for a way to to the following:

  1. take a screenshot
  2. copy that screenshot with a unique name to my webserver
  3. put the full url to the screenshot in my clipboard

See the method below.

	# create a directory 'screenshot' on the desktop
        mkdir ~/Desktop/screenshot;

	# go to that directory
        cd ~/Desktop/screenshot &&

	# capture a selected part of the screen
        screencapture -ix ~/Desktop/screenshot/$(date +%Y-%m-%d-%H-%M-%S).png &&

	# copy this screenshot to my hosting through ssh with scp
        scp ~/Desktop/screenshot/$(ls | xargs | awk '{print $1}')$(ls | xargs | awk '{print $1}') &&

	# add the url to my clipboard
        echo "$(ls | xargs | awk '{print $1}')" | pbcopy &&

	# get rid of this directory
        rm -rf ~/Desktop/screenshot;

Thanks to @davelens for his help. You can also follow his blog

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation