Created
October 10, 2013 07:10
-
-
Save mowat27/6914265 to your computer and use it in GitHub Desktop.
Scripts for working to todo.txt - as of 10 Cot 2013
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alias tlss='t ls | sort' | |
| alias tgrep='tlss | grep' | |
| alias tas='t add @stuff' | |
| alias tad='t add @delegate' | |
| alias taw='t add @wait' | |
| alias tat='t add @today' | |
| alias tal='t add @later' | |
| PATH=~/Dropbox/todo/bin:$PATH | |
| alias tstuff='tcon stuff' | |
| alias tdelegate='tcon delegate' | |
| alias twait='tcon wait' | |
| alias ttoday='tcon today' | |
| alias tlater='tcon later' | |
| alias tc=tcat | |
| alias topen='vi /Users/adrianmowat/Dropbox/todo/todo.txt' | |
| function tdo { | |
| t do $@ | |
| tcat | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Prints a report of your tasks grouped by @context | |
| module ToDo | |
| class Task | |
| attr_reader :entry, :num, :context, :desc | |
| def initialize(entry) | |
| @entry = entry | |
| entry.scan(/(\d+) (@\w+)* *(.+)/).each do |num, context, desc| | |
| @num = num.to_i | |
| @context = context || "no context" | |
| @desc = desc | |
| end | |
| end | |
| def <=>(other) | |
| self.num <=> other.num | |
| end | |
| def to_s | |
| entry | |
| end | |
| end | |
| def self.run(*args) | |
| %x{/usr/local/Cellar/todo-txt/2.9/bin/todo.sh -d #{ENV['HOME']}/Dropbox/todo/todo.cfg #{args.join(' ')}} | |
| end | |
| def self.tasks | |
| run(:list).split("\n").grep(/^\d+ +/).map {|entry| Task.new(entry)} | |
| end | |
| def self.contexts(tasks) | |
| tasks.map(&:context).uniq.sort | |
| end | |
| end | |
| tasks = ToDo.tasks.sort | |
| ToDo.contexts(tasks).each do |context| | |
| puts <<-EOS | |
| #{context} | |
| #{'-' * 50} | |
| #{ tasks.select {|task| task.context == context}.map(&:to_s).join("\n") } | |
| EOS | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Rewrites tasks to move them between context | |
| def usage | |
| STDERR.puts <<-EOS | |
| Usage: #{File.basename(__FILE__)} context task | |
| EOS | |
| end | |
| def todo(*args) | |
| %x{/usr/local/Cellar/todo-txt/2.9/bin/todo.sh -d #{ENV['HOME']}/Dropbox/todo/todo.cfg #{args.join(' ')}} | |
| end | |
| def get_task(num) | |
| todo('-@', :list).split("\n").grep(/^#{num} +/).first | |
| end | |
| if ARGV.count < 2 | |
| usage | |
| exit 1 | |
| end | |
| new_context = ARGV.shift.sub(/^@/, '') | |
| task_number = ARGV.shift | |
| task_description = get_task(task_number).sub(/^\d+ +/, '') | |
| puts todo(:replace, task_number, "@#{new_context}", task_description) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment