Julius Plenz – Blog

URL shortener

The bit.ly service requires some sort of registration or an API key for some time now. I used to use it in shell scripts to automate shortening of links.

Similar to the sprunge pastebin service, there's come up a new, easy-to-understand URL shortening service called gnzkrz (short for German "ganz kurz", "very short"). And with it's latest commit, it acquired a simple API. I use it as such:

#!/bin/sh
URL=`xclip -o`
SHORT=`wget -qO- "http://krzz.de/_api/save?url=$URL"`
(echo -n $SHORT | xclip -i -display :0 -loops 0 ) &
/home/feh/bin/notify-wrapper "krzz.de: switched URL in clipboard" "$SHORT"

Now I simply bind a hotkey to call this program, and it will exchange the URL from my X clipboard with a shortened version.

posted 2011-08-07 tagged sh and oneliner