Search.

Google
 

Tuesday, July 13, 2010

Working from the command line - GoogleCL

One might say "To what end would you use GoogleCL?" - and they'd have a very valid point. One can not deny the allure of doing something for the sake of being nerdy, but I've found that there is much more that GoogleCL offers.

At work, due to a somewhat draconian (and selectively enforced) IT policy I'm not able to access a variety of things that I use, namely Google Calendar set up through my Apps domain. Things like web-browsing, email, twitter, and IM are also restricted via the time tested method of shoulder surfing.

Now, my job also entails doing 95% of my work through various command line and shell utilities, so an extra SSH window open does not arouse anyones notice - and therein lies my secret: I do everything I need and want through an SSH session to my iMac at home.

This post will talk about how I have GoogleCL set up to provide me with information at my fingertips that I can use.

First, and primarily what I use GoogleCL for is the for integration with the Calendar portion of Google Apps (or Google Calendar if you don't use Apps). Adding an event is dead simple in its most basic form:
# google calendar add "Some Event at That One Place tomorrow from 6pm to 7pm"

This will add an event tomorrow called "Some Event" located at "That One Place" tomorrow from 6pm to 7pm in your default Calendar.

If you want to add an event to a specific calendar, just append the command with --cal="Calendar Name"

This becomes more useful as when I log in to my session, I'm greeted with the upcoming 24 hours worth of appointments set up in my Google Calendar:
[Calendar]
Lunch with Bob at Sushi Train,Jul 13 12:00 - Jul 13 13:00

[Football Schedule]

[On Call]
On call,Jul 13 18:00 - Jul 14 00:00
iShock:~ user$


How I have this set up is, in my .profile I have it calling a text file that is written to every hour with the google command for todays events via the crontab.

I've called the script gcal.script and it very simply just calls google calendar today for all my calendars, and writes it to a text file:
google calendar today --cal=.* > ~/MainDownloads/commandline_tools/synced_cal.txt

The --cal=.* is a regular expression to capture all calendars.

This script is called by a cron entry every hour:
#download google calendar to file for .profile
0 * * * * ~/MainDownloads/commandline_tools/gcal.script


And .profile is set to echo the file that is created whenever a new session is established (If you are on Linux, you'll likely put this in your .bash_profile in your home directory):
#google calendar for next 24 hours
echo "Calendar for the next 24 hours:"
cat ~/MainDownloads/commandline_tools/synced_cal.txt


Hope this has been has been helpful. Later I'll go in to how I use screen to put all the various programs I need in to one terminal window, that maintains state if I lose my session.

Have fun!

0 comments: