Send to Server Nautilus Action


I've pretty much given up on sending things via IM. Different IM networks, clients, OSes and firewalls have made it impossible to get a file from A to B without some sort of intermediary. So lately, I've just been throwing things I want to share up to a download directory on my server, and then giving a URL to whoever I'm talking to. This is especially good for screenshots, as Ubuntu happily saves screenshots as png images to your Desktop.

I was using Nautilus to browse via ssh:// to copy the file up to the server, and then typing out the URL manually in IM. But then I remembered that Nautilus has custom Actions you can add to the right-click menu. It might not be installed by default, so just "aptitude install nautilus-actions" should get it working.

First I added an action that just scp'ed the file up to the server, but then I decided I wanted to also check out the file in my browser to make sure it got there and was what I thought it was going to be, so I wrote a little bash script called


scp $1/$2


Then I set up the Nautilus Action like in the above screenshot, passing in the path and file names as separate params to the script. Probably a bash pro could easily divide them up in the script instead, but I just did it the easy way. It works like a charm now - I right click a file, choose send to server, and it'll copy the file up and when it's done and uses Firefox to check it out.

Of course, all this is contingent on you setting up SSH keys so you don't get prompted to login everywhere, but if you've got that working, this is pretty slick. I may have to explore a bit more and see if I can get bash to somehow copy the URL to the clipboard.

I can see this being very useful in the future for lots of little file-based actions I do.



Update: Thanks to antrix who left me a comment pointing out 'xclip' for accessing the clipboard - it isn't installed by default, but works great. Here's another version of the above script which sends the file to the server, and beeps when it's done:


scp $1/$2

echo$2 | xclip -i -selection "clipboard"

play -q /usr/share/sounds/info.wav

< Previous         Next >