Blog by Daniel Hauck. Sysadmin, Developer, Blogger.

TAG: calendar

Get your Google Calendar into TMUX

EDIT: If you need to have your caldav/owncloud calendar, have a look HERE.

The most time I work in the terminal in fullscreen mode for not getting disturbed. Therefore I like it to have my calendar(at least the next appointment) visible in my command line environment. I discovered a great tool for the command line called ‘gcalcli’. You can find it on github: https://github.com/insanum/gcalcli

Install it via pip:

pip install gcalcli

After the installation you need to setup your account on the first connection. You can do this for example by requesting your agenda:

gcalcli agenda

A browser window will popup which is requesting your confirmation to manage your calendar:
Screenshot from 2015-06-29 21-29-10

After confirming you are able to query your calendar with the command line – GREAT! 😉

As wouldn’t that be cool enough, let’s put the calendar into tmux.

First we need to build the build the output we a few pipes and stuff:

gcalcli --nostarted --calendar "" agenda --nocolor | cut -d " " -f 4- | head -2 | tail -1 | sed "s/^ *//g" | sed "s/    / /g" | cut -c1-19

Let’s cut off the date, redundant spaces, empty lines and all the useless stuff and finally get only the next event in the calendar.
Also I only want the first 20 chars of the name, so let’s cut this ;).

Be sure to replace GOOGLE_USERNAME with your accountname(everything in front of @gmail.com).

Now you have only the last element, so let’s get a nice calendar symbol and put it in our .tmux.conf.
Therefore your need to open your .tmux.conf modify the option ‘status-right’:
set -g status-right '📅 #(gcalcli --nostarted --calendar "" agenda --nocolor | cut -d " " -f 4- | head -2 | tail -1 | sed "s/^ *//g" | sed "s/    / /g" | cut -c1-19)'

So you are almost there, just save your file and reload your tmux config. So type your prefix(standard CTRL+B) and
:source-file ~/.tmux.conf

After a few seconds in the right bottom you should see your next event from the google calendar:
Screenshot from 2015-06-29 22-07-49
Nice! 🙂

In the next days I will write how to achieve this with your owncloud account.

Have fun and thanks for reading! 🙂

 

P.S.: Currently I am writing a bout about an effective workflow using tmux so don’t forget to opt in to the newsletter to get the latest updates on the work in progress.

There are no more results.