I have a hosted Wordpress blog running on my own domain. I've recently considered trying to build a custom URL shortener (a la bit.ly) that I manage and control using a very short domain. I'm wondering how I can achieve this.

You can then integrate this in your editor (the "Get Shortlink" button) and add a <link rel="shortlink"> in your header by hooking into the pre_get_shortlink filter, and returning http://g4p.it/{$post_id}.