A quick Textexpander hack

Textexpander on the Macintosh is one of the those utilities that becomes more and more useful over time.

Just the other week I was looking at some of Brett Terpestra’s snippets and trying to figure out how to use them for my workflow.

I often copy URL links for blog items between my RSS newsreader and a browser, like Firefox. But I really dislike the cruft that Feedburner puts into the URLs and I don’t want to save that cruft on any bookmarking services I might use.

So I figured that there had to be a sed recipe that I could use to trim off the URL cruft after the ?.

Sed is a wonderful program that makes life a lot easier on a unix based platform. Basically it will take a regular expression and then substitute whatever text you wish into the pattern matched.

I tried to match the starting hostname of the URL directly but then, in a flash of insight, realized that I could delete the stuff I didn’t want and still achieve the same effort.

So here’s my fancy script.

pbpaste | sed 's/\?.*//'

Output the current contents of the cilpboard and then delete everything after the question mark.