TextMate Todo
I just changed to having my "todo lists" in
TextMate. Previously I've used Omni Outliner and Tinderbox, but I wanted to experience the unix way for a few months. Pervasive user scripting inside a text editor is a major mental shift.
Here is a bit of scripting that fetches my current assigned tickets from our project's
trac site and replaces my current selection with todo items for the tickets:
#!/usr/local/bin/ruby
# Note: This script requires ruby 1.8
require 'open-uri'
require "rexml/document"
puts
xml = open("http://devsupport/cgi-bin/trac.cgi/report/4?format=rss").read
rss = REXML::Document.new xml
rss.elements.each("//item[author/text()='DanielVonFange']/title") { |element|
task = /(#[0-9]+): (.+)/.match(element.text)
puts "[ ] #{task[2]} - #{task[1]}"
}
Another small script is for my completed todo items. I click on a line, press command-shift-D, and the todo item vanishes from the list, and appears in a log file along with the time that I finished it, and what file it came from.
Log entry:
[X] Blog Textmate converting me to a unix head - Tasks rip, GTD completion.
in Blog 08:48 20041019 Tue
Log script:
#!/usr/bin/ruby
task_text = $stdin.read
task_text.gsub!(/[ ] /,"[X] ")
from = File.basename(ARGV[0],".txt")
File.open("/Users/dvf/Documents/Writing/Life/plan/Completed.txt",'a'){|archive_file|
archive_file.puts
archive_file.puts task_text
archive_file.puts " in #{from} #{`date "+%H:%M %Y%m%d %a"`}"
}
This script must be saved to a file, and then called as command, passing along the name of the current file being edited. So it the command in TextMate would look something like this:
ruby /path/to/script/task_completed.rb $TM_FILEPATH
These are just quick hacks, but I'm slowly learning the way of the scripted editor.
Posted by on 10/19 at 02:48 AM
Funny. The delete-line-and-archive script doesn’t seem to work for me. I put the path to the script as a command, and altered the path to ‘completed.txt’ in the script, but I get ‘parse error’…
Muh.
Posted by on 10/23 at 03:25 AM
Actually, I’m having a similar issue with this line:
task_text.gsub!("[ ] “,"[X] “)
Otherwise, everything works. Any ideas? My task lines look like this:
[ ] @office: Slack off for 20 minutes with TextMate and Ruby
The text gets put into the Completed.txt file ok, but it doesn’t have the X in the brackets. I’ve tried escaping the brackets with single and double slashes as well as no slashes at all. Any thoughts?
Thanks! Great script!
Posted by on 11/14 at 07:10 PM
Sean and I worked this out. I’ve updated the code in the post to the new way.
Posted by
Daniel Von Fange on 12/06 at 05:29 PM