Keyboard Maestro: Titling

I’ve recently been working on a new project (more on that soon I hope), where I have been titling content. My use of consistent styling for titling of various blog posts and the like has probably been less than consistent, so I figure that this was a good opportunity to have a got at turning that around. The Chicago Manual of Style choice of titling rules seemed pretty good and so I’ve gone with that, but consistency is key and ease of use is required, so here’s a little Mac automation using Keyboard Maestro that sorts it all out for me.

The Key

The cornerstone to the solution is the titlecaseconverter.com web site and a rather useful GitHub hosted Python script (tcc) by Nick Janetakis . The web site and script honestly do all the hard work, and to that end I’d very much like to share something from Nick’s project readme in regards to credit to titlecaseconverter.com.

The author of the site gave me permission to create and open source this script. He has put in hundreds of hours of effort into creating this service. If you want to support his work, he has a donation link on the bottom of the page.

The owner of the Title Case Converter site generates income from ads on his site, and using this CLI tool means you won’t be viewing those ads. Although truthfully, you probably have an ad blocker running so it doesn’t matter, but in either case if you find his service useful and it saves you time then donate something to him because without this service, this script won’t exist.

I would also add my thanks to Nick for making this script available.

Set-Up

Install the Python Script

Nick very handily provided an installation line you can run at the terminal to download the tcc (Title Case Converter) Python file and set it to be executable. I would advise you to check the raw code as a matter of course before running the command to ensure that you are downloading a valid copy.

sudo curl \
  -L https://raw.githubusercontent.com/nickjj/title-case-converter/master/tcc \
  -o /usr/local/bin/tcc && sudo chmod +x /usr/local/bin/tcc

The script has a few command line parameter options, and details are available on GitHub, but for my purposes, I’ve actually been able to use tcc with its default settings.

Keyboard Maestro Macro

Once the script has been installed, it’s on to the Keyboard Maestro macro that calls it.

The macro carries out the following steps.

  1. The current selection is copied to the system clipboard.
  2. The content of the clipboard is passed to the tcc script as a parameter and the result is placed on the clipboard and pasted. This replaces the current selection.
  3. The previous two clipboard entries are removed. That is the converted text and the unconverted text; thus restoring the clipboard to its original state.
  4. Play a sound as an audible cue.

You can build the macro yourself, or you can download it here.

Wrap Up

I have set a keyboard shortcut to trigger the macro, and I have it linked up on my Stream Deck too. I simply select the text I wish to title, trigger the macro and a moment later I have an updated title. This does of course require an Internet connection, and you are sharing content with a third party, so do keep those constraints in mind when using this.

Overall, thanks to the existence of the titlecaseconverter.com site and tcc I was able to solve my little headings challenge in under five minutes. Hopefully, with this post, you’ll be down to under two.

Author: Stephen Millard
Tags: | keyboard maestro | python |

Buy me a coffeeBuy me a coffee



Related posts that you may also like to read