Command Line URL Shortener

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 account.

Here’s the script:

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.
  • Save & you’re done. Copy any URL http or https and press Ctrl-Alt-R (that’s the default, use your’s if you’ve modified).



3 thoughts on “Command Line URL Shortener

Add yours

Have something to add? Do it here.

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

%d bloggers like this: