With the right commands, you can turn your favorite command-line text editor into a distraction-free Google Docs app, add new events to Google Calendar, upload images to Picasa or video to YouTube, backup your Google data, and more. Here's how it works.


On Friday, Google released GoogleCL, a saucy command line program that interacts with Google services from any *nix-friendly command-line prompt (on Windows, Mac, or Linux). We spent the weekend playing around with it, and now we're sharing a few of the coolest ways we've been putting it to use.

What You'll Need

Before you can execute any of the cool commands below, you'll need to have installed a few things to get GoogleCL up and running on your system.


If you haven't already, you'll need to have installed Python 2.5 or higher on your system. To do so, simply type python -V at your command line prompt (see screenshot).


Now that you've got everything up and running, let's take a look at some of the coolest tricks you can accomplish.

Use Your Command Line as a Distraction-Free, Google-Docs-Backed-Up Text Editor

Distraction-free text editors are all the rage these days, but who needs a fancy new application to give you a plain text word processor when GoogleCL can do the same thing—and when you're finished, upload your results to your Google Docs account every time you save. To fire up your own minimalist, distraction-free GoogleCL word processor from the command line, just try something like:


google docs edit —title "To-Do List" —editor vim

The command above will open and edit an existing document in your Google Docs account if one exists; if not, it'll create one with the title you've provided. The last piece, --editor , determines which command line text editor you'll be working in. If you're a whiz with vim, then you'll probably want to use that. If you're not all that familiar or comfortable with vim, I'd recommend editing using nano, a command-line based text editor that's a bit more like writing in a normal word processor, and will look like so:


When you're finished writing and want to upload your results to Google Docs, in nano type Control+X to upload the results to Docs and quit your text editor. (You can fire it back up to edit the same document at any time by just repeating the command above).




Quickly Add Any Event to Google Calendar with Plain Language

You can quickly add any event to your Google calendar with GoogleCL with one command and plain language. For example, if I were to simply type:

google calendar add "Dinner tomorrow at 8pm with Ellen at Figaro"


...and hit Enter, GoogleCL will create the event in Calendar and figure out what I meant about the when and where. It's the same Quick Add feature available on the Google Calendar site, but you don't have to fire up your web browser and wait for Calendar to load to use it. You can enter the who, what, where, and when, and Google Calendar will figure out the rest.

Upload a Folder of Images to Picasa


Sure you could open up the Picasa desktop app, but if you've got a folder full of old pictures you want to upload to Picasa in a jiffy, the GoogleCL upload tool is a great option:

google picasa create —title "My Awesome Pool Party" ~/photos/poolpartypics/*


As you've probably figured out, --title denotes that "My Awesome Pool Party" is the name of your new album, and the folder directory after that is the folder it's going to upload pictures from. You could upload an individual picture, but if you want to upload the whole folder, make sure you include the asterisk at the end of the path. When it's done, you should see all those pics up and ready to share on your Picasa Web Albums account. Pool photo from lepiaf.geo.

Upload a Video to YouTube

I actually hate using YouTube's web-based uploader, so I'm especially keen on this one. You can upload any video to YouTube like so:

google youtube post —category Technology ~/Desktop/maddow-talks-lifehacker.mp4

Schedule Backups for Your Google Data

Possibly one of the most useful ways you could put GoogleCL to use off the bat—particularly if you're paranoid with the idea of storing all your data online—is to back up the data from your Google services. In a single command for each service, GoogleCL can back up all of your Contacts, Docs, and Picasa photo albums, for example, and I'd guess the backup support will improve for most of the services. Here's how it works for Contacts, Picasa, and Docs.


Google Contacts

google contacts list > contacts_backup.csv

This will pipe all of your contacts to a comma-separated list that can easily be imported to other contact management applications or simply saved to a backup folder, just in case.


Picasa Photos

google picasa get *

Google Docs

google docs get * ~/Desktop/Doc_Backup/

Note: Docs backup isn't perfect just yet (spreadsheets aren't supported, and I had to enter the specific folder I wanted downloaded instead of it letting me grab everything at once, but GoogleCL was released on Friday and already updated once this weekend, so I'd expect some of these tools to get a lot better over time.


Expanding What GoogleCL Can Do with Other Tools

As you probably figured out after examining a few of the actions described above, GoogleCL's syntax is pretty simple. To execute a command, you simply type google , followed by the service you want to access (e.g., calendar), followed by the kind of action you want to perform using that service (e.g., create, edit, delete, post, etc.). Finally, you'll add some specifics after that action based on whatever it is you're doing (e.g., the file you want to upload, the title you want to give to a new document, or the event you want to schedule).


With other tools and tricks, you can do all sorts of fun stuff with your Google data. Over at Smarterware, Gina suggested using the Calendar tool to display your agenda for the day every time you open a new Terminal window by adding:

echo "Next 24 hours:";google calendar today title

...to your ~/.bash_profile file. Whitson suggested piping the results to a plain text file to use with something like GeekTool (Mac) or Rainmeter (Windows)—both of which can display plain text files on your desktop. A command like:

google calendar today title > myagenda.txt

...would do the trick nicely. (The greater-than sign pipes the output of any command to a file, so myagenda.txt would contain the same text returned in the command line.)


Cron It

Perhaps most useful, a lot of the tasks available—particularly related to downloading backups or uploading folders of pre-defined content—can get especially handy if you set them up to run as cron jobs. Cron schedules any command based on user-defined times, so you could set a cron job to, say, download backups of your Picasa photos on a weekly or nightly basis. If you're new scheduling with cron, check out IBM's introduction to cron.

If you've been toying around with GoogleCL over the weekend—or reading through some of these suggestions gave you some ideas—let's hear how you'd take advantage of GoogleCL in the comments.


Adam Pash, editor of Lifehacker, loves to play around with a cool new command line tool. His special feature, Hack Attack, appears regularly on Lifehacker. Subscribe to the Hack Attack RSS feed to get new installments in your newsreader, or follow @adampash on Twitter