Updated Bitlyize Service
I hope you’ve had nice holidays!
I’ve updated my Bitlyize service to work with v4 of the Bit.ly API. It parses the input for all URLs and replaces them with shortened links connected to your account. Not only can this make long links more readable, it gives you some analytics on how often the links are used (and deeper analytics like country of origin, referrer, and other data). If you pass it a Bit.ly-shortened link, it will expand it to its original URL.
The downside to shortened links is you can’t tell where they go, which can make them seem a little sketchy. You get to weigh the tradeoffs there. This service makes it easy to expand shortened URLs in place, though.
By the way, shortened links aren’t just obscured for readers and recipients, they’re opaque to future you as well. If you want to use short links for blogging or note taking, I recommend using the !bitly
function of SearchLink, which can give you title attributes. It requires separate configuration, but then instead of just a bit.ly link, you can run !bitly ++t Brett Terpstra project searchlink
and get [SearchLink](https://bit.ly/47lzuXS "SearchLink")
, which is a bit more descriptive. You can also just pass it a long url like [Marked 2.6.18](!bitly https://brettterpstra.com/2023/01/03/marked-2-dot-6-18-with-100-percent-less-jitter/)
and get [Marked 2.6.18](https://bit.ly/3ieHDcH "Marked 2.6.18 with 100% less jitter")
.
These Services require Ruby, which is no longer included with macOS by default. You can get it by installing the Apple Command Line Tools, or see this article for information on installing Ruby with Homebrew/ASDF. You don’t need Rails or anything after the Installing Ruby section in the latter article.
Anyway, download the Service below, double click to install, then set up a configuration file. The file should be located at ~/.config/bitly/config.yaml
and only needs two settings:
---
:token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
:domain: 'bit.ly'
To get your token, log into your Bit.ly account. If you don’t have one, you can create a free one. The whole point of using Bit.ly for this is to have trackable links, so you definitely need an associated account. Once logged in, go to https://app.bitly.com/settings/api. You’ll see a field where you can enter your account password (the same one you logged in with), then click Generate Token.
Assuming a correct password, you’ll be presented with a long alphanumeric string. That’s what you’ll copy into the :token:
setting in your config file.
The :domain:
setting is for users who’ve set up a custom domain. If you haven’t, you can just leave this set to ‘bit.ly’.
Once configured, just select any text containing at least one valid URL, run Services->Bitlyize (either from app menu or by right clicking) and give it a couple seconds to contact the API.
If you’re curious about how I’m running Services these days, as shown in the movie above, that’s an app called Paletro that gives you a command pallete in any app. Available on Setapp.
This Bitlyize Services will swap whatever type of link its passed, so if your text contains both long and short URLs, the long ones will be shortened and the short ones will be lengthened. If your text contains a mix of short and long urls and you want them all to be either shortened or lengthened, use the
Shorten
orExpand
Services individually.
Download
The download includes a few services, Bitlyize
and Bitlyize to Clipboard
, as well as Bitly Shorten
, Bitly Expand
and Bitly Preview
. The base Bitlyize Service will auto-detect link type and either shorten or expand them. The Clipboard version simply outputs the result to the clipboard rather than trying to paste it, so you can use it on selected text in non-editable fields. The Shorten/Expand versions will only shorten or lengthen, rather than swapping whatever type is detected. The Preview version is designed to run on a single shortened link and show you a preview of the lengthened version for verification/safety before clicking a short link.
If you want quick previews of multiple urls, shortened or long, I recommend my CheckURLs PopClip Extension.
Bitlyize Service v2.0.0
Download Bitlyize Service v2.0.0
An OS X Service for quickly creating bit.ly short urls
Published 04/30/14.
Updated 12/24/23. Changelog
This version no longer adds affiliate codes to Amazon and iTunes links. iTunes doesn’t really pay out anymore, at least for apps, and Amazon has their own URL shortener that I haven’t figured out a way to tap into programmatically yet.
If you’re curious, here’s the script used in all of the Bitly Services. You can modify its utility by changing the function
and output
settings as shown in the comments.