On my computer, I use Gentoo Linux with KDE. If you’re a KDE user, you might be knowing that the default clipboard tool known as Klipper has the ability to execute commands when a new entry copied to the clipboard matches regex. That’s how the idea of having a handy URL shortener came to my head.

I built a small URL shortener script using Python which would accept the source URL and output the shortened URL, using my bitly.com account.

It’s available on my utilites GitHub repository as well. The regex I’ve used in the script seems to match all kinds of URLs that I generally came across; if you find bugs, either comment or fork & push (preferred) on GitHub.

Coupling it with Klipper –

Place the script in $HOME/bin and set it is executable.

Go to actions in Klipper’s settings

In actions, create a new action and put the path of script as /home//bin/shorten (or whatever). Keep the rest same.