A buddy of mine is ramping up his command-line fu lately. He’s a thorough notetaker, and he’s taken to commenting his shell code immaculately. I applaud this. He mentioned that he really liked this particular formatting for describing what each flag/switch in a command does:
I dug it, but my first though was how tedious it would be to type out, even with handy TextExpander snippets. So I made a thing. A silly little thing of limited utility, to be sure. But a thing.
The “Comment Flags” Service will simply scan a line for a grouping of characters following a dash, e.g. the “ltr” in ls -ltr *.md
. It will then output a “diagram” for comments like what you see above (minus the actual comments), ready to be filled in.
It will work for multiple groupings (or even multiple single flags). For example, it provides this, ready for all the explaining:
It ignores long flags. They’re more descriptive anyway, but I might add some formatting for those in the future.
Figured I’d share this, just in case it scratches anyone else’s itch.
Comment Flags Service v1.0.1
Download Comment Flags Service v1.0.1
A Service to make pretty comments for switches/flags in command line examples
Published 03/25/21.
Updated 12/31/22. Changelog
By the way, TextBuddy (this week’s gracious sponsor) can run Services now. That means things like this Service, all of the Markdown Service Tools, and even SearchLink can all work in TextBuddy from a single popup palette alongside its own extensive toolset. It’s a secret setting you have to enable from Terminal, but if you’re curious scroll down this page a bit. You know, to the part where Tyler says in 21pt type “Please Don’t Tell Anyone About This…”