GTD with iPod Notes -- Hacking Journal [2006/03/23]
I just recently moved back to using text files to keep track of my todo lists. I tried separating all my contexts into separate files but I noticed I spent too much time switching between the files. So I now joined them all into one large file, my large todo.txt. The only issue with that is that this file is 5.2K right now without a lot of task in it and my iPod’s Notes program can only access the first 4K of a text file.
I could have split the todo.txt at 4K and used hyperlinks to link them together but that could really start to confuse things. Instead I wrote a Ruby script to split out my contexts into separate text files. These can then be sync’d to the notes section of the iPod and then the master todo.txt can be sync’d to the actual disk area of the iPod. Instant lists on my iPod.
Here is the code I cam up with. It is a quick hack and is very specific to my use but it should help to give an idea of the process to any others who have a similar problem.
#!/usr/bin/env ruby
###############################################################################
# COPYRIGHT 2006 Eric Davis ("eric" + "at.to_sym" + "theadmin.org")
###############################################################################
#
# This is a script to split up my todo.txt file into many smaller files based
# off the category delimiters of "==="
#
# Example todo.txt:
#
# === Home ===
# Task 1
# Task 2
#
# Task 3
#
# === Work Stuff ===
# ...
#
# Will create two files "home.txt", and "work_stuff.txt" and put the 5 lines
# from Home into "home.txt" and the two lines from Work Stuff into
# "work_stuff.txt"
#
###############################################################################
require 'fileutils'
# Make a folder split
FileUtils.mkdir_p 'split'
FileUtils.cd 'split'
# Read the todo from the original folder
file = IO.readlines("../todo.txt")
# Use a tmp variable so I can skip the first close
first_run = true
f = String.new
file.each do |line|
if line.include? "==="
f.close if not :first_run
new_file_name = line.gsub(/=/, '').strip.gsub(/ /, '_').downcase + '.txt'
if new_file_name == "todo.txt"
puts "\n*** Error *** \nYou have a category TODO in your todo.txt\n" +
"and I will not overwrite it" + "\n"
exit
end
f = File.new(new_file_name, "w")
first_run = false
end
f.puts line
end
f.close
Eric Davis
