What OSX `pbcopy` Should Have Been

I sometimes wish pbcopy and pbpaste were the same command, and the command just Did What I Mean.

Although pbcopy and pbpaste can be used to do more than simply copy text data into and out of the general system clipboard, in practice, I never use those features. In fact, I sometimes find it annoying that there wasn’t just one tool provided that sensed if there was data on STDIN, copied it to the clipboard, and pasted data appropriately from the clipboard on STDOUT.

In fact, the more I thought about it, the more I thought it should do both.

Colored Glasses for Less

Eine kleine Probleme

Sometimes you’ll want to view some output in less, the default PAGER, and you’ll realize that the output was colorized with ANSI escape sequences.

Bundling Binary Blobs

Every once in a blue moon, the following hack comes in handy, and I have to look it up again. I don’t remember where I first saw this technique in the wild, but I remember being blown away when I realized what was going on.

Lightning Talk at Triangle.rb!

Last night, I gave a 5-minute “Lightning Talk” at Triangle.rb, entitled “Compose with Confidence”. Here are the slides and audio:

Someone asked what I used to generate the slides. I used mdpress, which in turn uses impress.js for the Prezi-like transitions.

Compose With Confidence

Last time, I noted that the experience of composing shell functions at the command prompt is awkward. Here’s what works for me, and why.

Servant of Two Masters

Last time, I brought up the subject of fixing shell commands as you go along, and suggested that the practice of doing so could be good for your programmatic health. Today I’d like to highlight an underused Unix command that does this well, and talk through the broader implications of its use.

Broken Windows and Broken Code

In the previous post I talked about the Useless Use of Cat, and suggested that this is a habit worth breaking.

Really, though—isn’t There More Than One Way To Skin A Cat? If cat with a single file argument gets the job done, who besides Randal Schwartz cares?

I care, and I think you should too.

Curious Case of the Disappearing Cats

As any Unix veteran will tell you, the cat utility is much abused. Here’s the common scenario:

Useless Use of Cat
1
cat myfile | grep mypattern

Of course, this kind of abuse isn’t limited to the “pipe to grep” variety. Here’s the general form:

It’s not good for my… idiom.
1
cat <file> | <command> arg1 arg2 argN

Indeed, flaming other Unix users for the Useless Use of Cat has long been the ‘national sport’ of the Unix tribe, since Usenet days.

Hello World

cats.each do |cat|
  cat.kill if cat.curious?
end