Sunday, 13 April 2014

Edit Google Docs using Vim with googlcl



Installation
  • On Ubuntu or Linux Mint : 
$ sudo apt-get install -y googlecl

Authorization
  • The first time you access the service you need to Authorise the googlecli
  • Run the following command
$ google docs list
  • You will then be prompted for your email address and a browser will open asking for Authorization from this computer
  • Enter the provided browser Authorization code to the CLI
  • After this your Google Docs will be listed
Google Docs list with grep
  •  You can grep on the list command e.g.
 $ google docs list | grep Linux
  • Other Unix commands can be used in a similar way
Configuration File

  • Once the Authorization has occurred you can review the config file :
$ cat ~/.config/googlecl/config
  • Example configuration file :
$ cat ~/.config/googlecl/config

[DOCS]
spreadsheet_format = xls
format = txt
spreadsheet_editor = openoffice.org
presentation_format = ppt
presentation_editor = openoffice.org
document_format = txt
drawing_format = png
skip_auth = True
user = cwishaw@example.com

[CALENDAR]
fields = title,when

[GENERAL]
regex = True
url_field = site
missing_field_value = N/A
fields = title,url-site
cap_results = False
max_retries = 2
hostid = example@computername
retry_delay = 0.5
date_print_format = %b %d %H:%M

[YOUTUBE]
max_results = 50

[CONTACTS]
fields = name,email

 

Set Vim as Default Editor
  • Update [DOCS] section with line in red
[DOCS]
 

editor = vim
spreadsheet_format = xls
format = txt
spreadsheet_editor = openoffice.org
presentation_format = ppt
presentation_editor = openoffice.org
document_format = txt
drawing_format = png
skip_auth = True
user = cwishaw@example.com

  • Open a Google Doc e.g.
$ google docs edit "Hello Google Docs"
  • Edit and save it as normal


  • View in Google Doc's


Alias Setup

  • It can be useful to have some alias setup e.g.
alias gvi='google docs edit $1'
alias glist='google docs list'

  • Command examples 
$ glist | grep -i hello
$ gvi "Hello Google Docs"


Further References

No comments:

Post a Comment