I use my simple Emacs Todo mode to keep track of my todo items but one thing that I’ve been missing has been recurring tasks. A calendar with recurring events works okay but I still have to remember to copy them into my todo list or I forget about them.
So tonight I whipped up a simple Ruby script that adds daily, weekly, or monthly todo items to my list. The best parts about it is that is that it is simple to add or remove a recurring item (just edit the yaml file) and I have the full power of ERB if I need it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#!/usr/bin/env ruby # /home/edavis/bin/recurring_todo.rb require 'yaml' require 'erb' require 'rubygems' require 'trollop' require 'active_support' opts = Trollop::options do opt :daily, "run daily todos", :default => false opt :weekly, "run weekly todos", :default => false opt :monthly, "run monthly todos", :default => false end @todos = YAML.load(ERB.new(File.read("/home/edavis/doc/T/Todo/recurring.yml")).result) def save_todos_to_file(schedule) File.open("/home/edavis/doc/T/Todo/Todo.todo", "a") do |file| @todos[schedule].each do |todo| file.puts todo end unless @todos[schedule].nil? end end save_todos_to_file(:daily) if opts[:daily] save_todos_to_file(:weekly) if opts[:weekly] save_todos_to_file(:monthly) if opts[:monthly] |
# /home/edavis/doc/T/Todo/recurring.yml <% monday = Date.today.beginning_of_week tuesday = monday + 1 wednesday = monday + 2 thursday = monday + 3 friday = monday + 4 saturday = monday + 5 sunday = monday + 6 %> --- :daily: :weekly: - "2 Weekly review #<%= saturday.strftime %> #gtd" <% [monday, wednesday, friday].each do |day| %> - "2 Water houseplants #<%= day.strftime %> #garden" <% end %> - "2 Redmine tip #<%= wednesday.strftime %> #marketing" - "2 Weight metrics #<%= saturday.strftime %> #health" - "2 Balance finances #<%= saturday.strftime %> #finance" - "2 Pay bills #<%= saturday.strftime %> #finance" - "2 Grocery shopping #<%= saturday.strftime %>" - "2 Check garden #<%= saturday.strftime %>" :monthly: - "2 Monthly review for <%= Date::MONTHNAMES[Date.today.month] %> #gtd" - "2 Business goal review #business" |
# crontab @monthly /home/edavis/bin/recurring_todo.rb -m @daily /home/edavis/bin/recurring_todo.rb -d @weekly /home/edavis/bin/recurring_todo.rb -w |
Example Output
$ /home/edavis/bin/recurring_todo.rb -m -w -d
(I use hashtags for due dates, GTD contexts, GTD projects, and general categorization)
Feel free to use or adapt it for yourself. I don’t think it’s worth it to put it on Github.
This is a cool little script – but I have to ask – if you are emacs user already, what about using http://orgmode.org/ ?
I used to use orgmode with planner.el (http://theadmin.org/articles/2006/07/26/emacs-planner-el-and-gtd/) but I didn’t like the format of it for my todos. Since I work on multiple computers, sometimes the counter would get mess up if I added todo items in two places. Now my format is much simpler and easy to merge in git. “X TODO” where X is the priority and causes the font-lock:
1 – today
2 – this week
3 – this month
4 – later
A – Annual goal
D – Dream
L – Lifetime goal
I do use orgmode for my notes files though. Great for that, just not as good for todo items (at least for me).