Home > Utility > Titlecase at the Command Line (and Mac OS X Services)

Titlecase at the Command Line (and Mac OS X Services)

Sometimes I want to change a line of text to titlecase Where Every Word Is Uppercase, and I am rarely in a program that offers that feature natively. I am usually at the command line or in a web browser or some such thing. To that end I put together some command line scripts and an Automator Service so that I could have an appropriate filter.

Download

You can jump right to the download of the titlecase command, the titlecase.awk awk script, and the Titlecase.workflow Service.

Installation

Copy the titlecase and titlecase.awk files to a bin directory somewhere such as /usr/local/bin, if you have that in your path. If you copy then somewhere else, you will have to update the Titlecase.workflow file in Automator. Copy the Titlecase.workflow file to ~/Library/Services.

Usage

At a command prompt, one can simply pipe text into titlecase to correct the capitalization:

$ echo hello world | titlecase
Hello World

From any Mac program highlight some text, and find your Services menu. You might right-click (or control-click) to get to it, or you can go to the main application menu.

Titlecase Service Menu Item

Credit

Astute shell scripters will notice that in fact all the hard work is done in the titlecase.awk script which I claim no credit for. It was written by Eric Pement at www.pement.org.

Categories: Utility Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.