Dumping to the Internets

I am constantly uploading files and pasting people URLs to said files hosted on some web server. After many years of typing the scp command and then manually transcribing the resulting URL, I finally made my life easier.

I shared it with some friends on IRC and everyone seemed to find it the most revolutionary script of 2008, so maybe it’s useful to the rest of the world.

In addition to printing the URL on the terminal, it also copies the URL into the primary X clipboard. This allows me to run the command upload foo and then quickly middle click the URL into IRC or a browser.

[[ $# -lt 1 ]] && { echo "Not sure what to do..." 1>&2; exit 1; }
scp -r $* $user@$host:public_html && {
	URL="http://$host/~$user/$(basename $1)"
	echo "$URL"
	xselection -replace PRIMARY "$URL"

It assumes you have your ~/public_html directory on the server being shared over HTTP at /~username. In openSUSE 11.0, the xselection command is provided by, you guessed it, the xselection package.


8 Replies to “Dumping to the Internets”

  1. @David: it would, but for me when I need to upload something, I’m already working in a terminal ;-)

    @derfian: Nice idea about notify-send. The xselection part of the script is really what makes this so useful to me.

  2. I have some thing similar but for a nopaste site and imageshack I make it it an icon on the bar… I you click it it uploads the clipboard.. if you drop a text file on it uploads the content… if you drop an image it uploads the image

    Really handy stuff

  3. @Barry: good point and good fix! Though I typically only care to share things I create and name, which I am known to do in a sane and consistent manner :-)

    @Killerkiwi: nice! That sounds useful.

  4. Nice tips about the xselection command.

    @Killerkiwi : would you mind sharing your script, it sounds really useful.

  5. Thanks for this post. It makes so much sense. I’m always ftp’ing files up to share screenshots, recordmydesktop files, etc.

    I tend to upload to a couple of hosts based on if this is for work or public so I started a python project to handle some more use cases.

    It’s a lot more overhead, but now that I’ve got it I’m already mad I didn’t do this a long time ago.

Comments are closed.