Having a ball playing around with the just-released GoogleCL tool, which offers command line access to Google Calendar, contacts, Docs, Picasa, Blogger, and YouTube. With Python-based GoogleCL installed, you can do things such as list today’s events on your GCal right in the terminal, like so:
$ google calendar today title
Coffee with Michael and Samir
Dozing off
Lunch at Flingers
Instant use case: Add echo "Next 24 hours:";google calendar today title
to your ~/.bash_profile
file to see what you’ve got scheduled for the day when you launch a new Terminal window. Some more GoogleCL fun inside.
If you just type google
at the command line, you launch an interactive terminal that lets you try all the various commands. In the interactive terminal, type command-name help to see its options, like help calendar
.
Each command has several parameters that aren’t immediately apparent. For example, in calendar, you can omit the long and hairy event URL by using the title
parameter. You can list events for a particular day using the data parameter (--date 2010-06-16
), and you can get events from a particular calendar and by keyword search term.
For example, to see all my trips to NYC on my TripIt calendar, I’d use the command:
$ google calendar list --cal TripIt --query NYC
Remember the beauty of the command line: you can easily chain commands together with the pipe, so you can sed
, awk
, and grep
output to your heart’s content, and then write it to a file if needed, using >
. Before I discovered the title
parameter on the calendar
command, I was planning to use sed to filter out the calendar URLs from the output. (Thanks to lightening-fast sed and awk experts on Twitter, I was prepared to do just that.)
What I’d love to do is create a Todo.txt CLI add-on that inserts an event on your Google Calendar when you add a task with a due date. Here’s the discussion about that going on now on the Todo.txt CLI mailing list. It’s pretty much a no-brainer.
While I’ve mostly only played with calendar, the Docs access is pretty useful, too. With it, you could easily schedule cron’ed backups of your Google Docs, or push data into a new doc on a regular basis. Same deal with Picasa and YouTube. I like the idea of cron’ing a job that backs up my Google contacts to a CSV file on my local computer weekly, too. I don’t see myself ever blogging from the command line, but it’s neat that you can.
How are you using GoogleCL? Post your favorite command combos in the comments.
9 Comments
Ramón
Wow, this is pretty awesome! I wrote this script and added a launcher to my panel in Ubuntu to execute it. It displays my calendar events for the next 24 hours in a OSD notification.
#!/bin/bash
#
#events from Google calendar in the next 24 hours in an OSD notification
google calendar today title,when --delimiter=", " > /tmp/24hrs.txt
current_time=`date +%r`
msg="The current time is $current_time"
while read event;
do
msg="$msg
------------------
$event"
done < /tmp/24hrs.txt
notify-send "Events in next 24 hours" "$msg"
rm /tmp/24hrs.txt
exit 0
Too bad ‘today’ does not actually return today’s events. Also the ‘–date’ option seems a little buggy.
Chad Stephen Albert
I made up a shell script that dumps today’s calendar events to a text file that gets displayed in Conky on my desktop. Nice clean list of the days events above a todo.txt list. The text file is in Dropbox, so it’s across several locations for use on other machines.
#!/bin/bash
google calendar today title >today.txt
use a simple cron job to update the today file every however often, and you’re good to go….
Gina Trapani
@Chad: the Dropbox component is a great idea.
@Ramon: I didn’t know about when, or the delimiter!
My new favorite calendar command:
$ google calendar today when,title --delimiter " | "
rashwell
Why not create the cloud version of todo.txt by having it automatically store is data in a google docs spreadsheet?
Barron Bichon
I’m no BASH expert, but here’s what I threw together to show the start times of events for the next week in an alternate date format:
!/bin/bash
BEG=$(date "+%Y-%m-%d")
END=$(date -v+7d "+%Y-%m-%d")
google calendar list -d $BEG,$END when,title > gcal.tmp
while read line
do
G_DATE=${line:0:12}
MY_DATE=$(date -j -f "%b %d %H:%M" "$G_DATE" "+%A %l:%M %p")
echo $MY_DATE "-" ${line:28}
done < gcal.tmp
\rm -rf gcal.tmp
google.com/profiles/ca…
Does anyone know if there is a way to display subscribed calendars (non-editable) in Google CL?
tuckerbrennan
Wow. Downloading my Picasa albums from a command line was a borderline religious experience.
Jon White
want to add my todo.txt file to google docs but when I upload it creates a new file each time. How can I overwrite it?
Sufian Siddiqi
I’ve got multiple calendars on my account so I use the following to retrieve all events for the day via terminal:
echo “Next 24hrs: “;google calendar today when,title –delimiter ” | ” –cal “.*”