Tom Says: Safe code is boring code!
Take notes from your (Linux) terminal! It works, if you treat each note file as an item in your inbox. I trade readable file names for tagging within each file, and speed in creating new notes.
I created the directory ~/docs/ for these notes. Here are the scripts, though I no longer use them religiously.
Print the current date and time without spaces. This is used later.
#!/bin/sh date +%Y-%m-%d_%H-%M-%S
This creates a new note and starts editing it with VIM.
#!/bin/sh vim ~/docs/`timestamp`
To find notes before you've had a chance to copy them to someplace better, use this script. It takes keywords (passed to grep) as arguments, though you can enter more once the program is running to narrow your search. When there is one result, or you type "XX)" (where XX is the index of one of the results), the corresponding note is opened by the editor in your EDITOR environment variable, or VIM when you haven't set it.
#!/usr/bin/env ruby
editor = ENV['editor'] || "vim"
Dir.chdir("/home/tom/docs")
def find_by_keywords(keywords=[],files=nil)
final ||= Dir["????-??-??_??-??-??"]
keywords.each do |arg|
final_copy = final
final = []
`grep -il #{arg} *`.each_line do |line|
final << line.chomp if final_copy.include? line.chomp
end
end
final
end
keywords = ARGV
results = find_by_keywords(keywords)
while results.length > 1
puts "Found #{results.length} results:"
puts
results.each_index do |i|
puts "=================="
puts "#{i}) #{results[i]}"
`head -n 7 #{results[i]}`.each_line do |line|
puts "> " + line
end
puts "=================="
puts
end
puts "New keywords? "
input = $stdin.gets
if input =~ /^[0-9]+\)$/
results = [results[input.to_i]]
else
keywords = keywords | input.split
results = find_by_keywords(keywords,results)
end
end
puts "Found #{results.length} results"
system "vim #{results.first}" if results.length > 0
Posted Mar 14, 2007, in the morning.