Skip to content

Instantly share code, notes, and snippets.

@GregPK

GregPK/tn.rb

Created Aug 4, 2019
Embed
What would you like to do?
tn - a taskwarrior script to show my my most important tasks
#!/usr/bin/ruby
require 'time'
filters = []
configs = []
hour = Time.now.hour
def is_weekend?
t = Time.now
t.saturday? || t.sunday?
end
if is_weekend?
configs << 'rc.urgency.uda.project.Me.Skills.coefficient=4'
configs << 'rc.urgency.uda.project.Fun.coefficient=4'
configs << 'rc.urgency.uda.project.Toptal.coefficient=-8'
end
if hour >= 19 # should be winding down now
configs << 'rc.urgency.uda.project.Toptal.coefficient=-5' unless is_weekend?
if hour >= 22 #too late for work, good time for relax
filters << 'project!~Toptal'
configs << 'rc.urgency.uda.project.Fun.coefficient=5'
end
end
filters_str = "'(" + filters.join(' and ') + ")' " unless filters.empty?
configuration_str = configs.join(' ') + " " unless configs.empty?
cmd = "task #{filters_str}#{configuration_str}next limit:3"
puts cmd
system cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment