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 bitly.com 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
    klipper
  • In actions, create a new action and put the path of script as /home//bin/shorten (or whatever). Keep the rest same.
    klipper-action
  • 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).

[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]

Advertisements

3 thoughts on “Command Line URL Shortener

Add yours

Have something to add? Do it here.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

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

Up ↑

%d bloggers like this: