Emacs‘ org-mode is just a mind blowing tool for organizing everything – there is a full Google Tech Talk only about this extension. Among other things I use it for my scheduling and todo lists. Sometimes (e.g. when I start my computer in the morning) I just want a quick glance at my today’s appointments and top todo items without opening Emacs and starting the agenda view. Due to this I created a simple setup that dumps this information into the command line.
To do so you first must have a org-mode formated file. If you need basic information about how to use the org-modes read its excellent documentation. Here is a sample file that I named “projectes.org”. It has the following made-up content:
* Project Boing ** TODO [#A] Make a the plan ** TODO [#A] Write the specs ** TODO [#A] Write the code DEADLINE: <2010-08-27 Fri> * Project Blub ** Meet the others SCHEDULED: <2010-08-25 Wed> ** TODO [#B] Dream up something ** TODO [#C] Slacking
You need to add this file to the list of agenda files in your Emacs configuration file (~/.emacs) so that the org-mode will include it in the agenda display:
(custom-set-variables '(org-agenda-files (quote ("~/projects.org"))))
If you have Emacs running, the org-mode installed and activated “M-X org-angenda a” will give you an overview of the dates and “M-X org-angenda t” will present your todo list.
To call this function from the command line instead of inside of Emacs use the editors batch mode:
$ emacs -batch -l ~/.emacs -eval '(org-batch-agenda "a")' 2> /dev/null
The “2> /dev/null” takes care of some extra and for us not useful information. The output should look like this:
Week-agenda (W34): Monday 23 August 2010 W34 Tuesday 24 August 2010 Wednesday 25 August 2010 projects: In 2 d.: TODO [#A] Write the code projects: Scheduled: Meet the others Thursday 26 August 2010 Friday 27 August 2010 projects: Deadline: TODO [#A] Write the code Saturday 28 August 2010 Sunday 29 August 2010
If you run this on a different date the output will look different. Today – the 25th of August – it is 2 days to the deadline that ends at the 27th. Again – to fully understand everything I can just refer you to the org-mode documentation. In order to get the todo list written to the command line we have to adapt the call just slidely – replace the “a” by a “t”.
$ emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' 2> /dev/null
The output should look similar to this:
Global list of TODO items of type: ALL Available with `N r': (0)ALL (1)TODO (2)DONE projects: TODO [#A] Make a the plan projects: TODO [#A] Write the specs projects: TODO [#A] Write the code projects: TODO [#B] Dream up something projects: TODO [#C] Slacking
Finally make some handy aliases in your ~/.profile file:
alias todo="emacs -batch -l ~/.emacs -eval '(org-batch-agenda \"t\")' 2> /dev/null " alias today="emacs -batch -l ~/.emacs -eval '(org-batch-agenda \"a\")' 2> /dev/null "
Now you can get the wished output by typing “todo” or “agenda” in the command line.