Writing, publishing, geekdom, and errata.

Software: GCalCLI (and how to replace straight quotes with SED)

No comments
GoogleCL was a nice program to get quite a bit of your Google information in and out of the cloud via the commandline instead of a bloated interface. For example, I used it to pull down my agenda from Google Calendar and then incorporate that into all sorts of fun things.

It is (was, depending on when you read this) hosted on Google Code (and quite a few people have exported it to GitHub - here's one example.

But there's been problems with the API for the Google Calendar for a while. (Non-tech version: It stopped working.)  In comes GCalCLI, which uses API version 3 (Non-tech version: it works). 

It is also a LOT more powerful than GoogleCL's version was - especially in terms of customization and display.  Take a look at this screenshot from the repository:

This works really well for me, except for one thing - I often pipe the output through other scripts.  Many of which use "straight" quotation marks to mark where they are supposed to start and stop doing things.

...and many of my events (like Bob's birthday or Go to "the thing" at someone's place) also include straight quotes, so my scripts fail.

Luckily SED (mentioned here before) comes to the rescue.  (Presuming your terminal supports UTF-8, of course.)

gcalcli agenda | sed "s/'/’/g" | sed 's/"\(.*\)"/“\1”/g'

Obviously, this little trick will work anywhere you need to turn straight quotes into smart quotes (as long as they're paired), and you can swap the straight and smart quotes in order to reverse the effect when you need to remove smart quotes.

No comments :