Monday, August 16, 2010

Cleaning a url from the klipboard and opening the file.

I find myself wanting to open a file that I've copied from the url quite a bit.

1. Copy the url.
2. Open the necessary program.
3. Choose open, paste the link.
4. Edit the file.

I want to reduce this 4 step process to one. The problem is that the full URL has 'localhost' junk in front of it, and I want to trim that out.

It would be faster if I could bind all these actions to F6. Here is how to do it:

Here is a little script that yanks the clipboard content of what you just copied and returns it:

Put this in a bash script, give it permissions to execute:

#!/bin/sh
clipboard_contents=$(dcop klipper klipper getClipboardHistoryMenu > /tmp/klippercontents; head -1 /tmp/klippercontents)
clean_the_url=$(echo $clipboard_contents|sed 's/file:\/\/localhost//g')
echo $clean_the_url

Then go to the control panel, go to accessibility and 'input actions' and add a new keyboard shortcut. Bind it to F6 and use the following command:

bluefish `clean_bluefish_url.sh`

I've been using it all the time. It's a nice little hack.

0 comments:

Post a Comment