diff --git a/.task/backlog.data b/.task/backlog.data index a0f1d81..570b36b 100644 --- a/.task/backlog.data +++ b/.task/backlog.data @@ -94,3 +94,6 @@ {"description":"touch filtered: point out tasks matching a non-editing filtered command","entry":"20230831T090935Z","modified":"20230831T090935Z","status":"pending","uuid":"c5835e89-fd7d-45bf-82ed-b38cd0d56b43","tags":["feat"]} {"description":"touch filtered: point out tasks matching a non-editing filtered command","entry":"20230831T090935Z","modified":"20230831T090942Z","start":"20230831T090942Z","status":"pending","uuid":"c5835e89-fd7d-45bf-82ed-b38cd0d56b43","tags":["feat"]} {"description":"touch filtered: point out tasks matching a non-editing filtered command","end":"20230831T091433Z","entry":"20230831T090935Z","modified":"20230831T091433Z","status":"completed","uuid":"c5835e89-fd7d-45bf-82ed-b38cd0d56b43","tags":["feat"]} +{"description":"humanize dates: make dates readable to a human being","entry":"20230831T092044Z","modified":"20230831T092044Z","status":"pending","uuid":"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29","tags":["feat"]} +{"description":"humanize dates: make dates readable to a human being","entry":"20230831T092044Z","modified":"20230831T092056Z","start":"20230831T092056Z","status":"pending","uuid":"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29","tags":["feat"]} +{"description":"humanize dates: make dates readable to a human being","end":"20230831T094605Z","entry":"20230831T092044Z","modified":"20230831T094605Z","status":"completed","uuid":"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29","tags":["feat"]} diff --git a/.task/completed.data b/.task/completed.data index 7f930ac..92b1c89 100644 --- a/.task/completed.data +++ b/.task/completed.data @@ -1,3 +1,4 @@ +[description:"humanize dates: make dates readable to a human being" end:"1693475165" entry:"1693473644" modified:"1693475165" status:"completed" tags:"feat" tags_feat:"x" uuid:"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29"] [description:"touch filtered: point out tasks matching a non-editing filtered command" end:"1693473273" entry:"1693472975" modified:"1693473273" status:"completed" tags:"feat" tags_feat:"x" uuid:"c5835e89-fd7d-45bf-82ed-b38cd0d56b43"] [description:"theme config: use taskwarrior theme config and extends from there." end:"1693324188" entry:"1692471868" modified:"1693324188" priority:"H" status:"completed" tags:"feat,themes" tags_feat:"x" tags_themes:"x" uuid:"6b248843-1b11-487b-85e8-a96e668f6772"] [description:"hide grouped fields: when &open;sub&close;grouping, hide the grouped field from the task display" end:"1693323123" entry:"1693322866" modified:"1693323123" priority:"M" status:"completed" tags:"feat" tags_feat:"x" uuid:"ec74a19f-8ab3-4911-b8d8-3b79a593a5d3"] diff --git a/.task/undo.data b/.task/undo.data index 6c1b794..de80fe5 100644 --- a/.task/undo.data +++ b/.task/undo.data @@ -347,3 +347,14 @@ time 1693473273 old [description:"touch filtered: point out tasks matching a non-editing filtered command" entry:"1693472975" modified:"1693472982" start:"1693472982" status:"pending" tags:"feat" tags_feat:"x" uuid:"c5835e89-fd7d-45bf-82ed-b38cd0d56b43"] new [description:"touch filtered: point out tasks matching a non-editing filtered command" end:"1693473273" entry:"1693472975" modified:"1693473273" status:"completed" tags:"feat" tags_feat:"x" uuid:"c5835e89-fd7d-45bf-82ed-b38cd0d56b43"] --- +time 1693473644 +new [description:"humanize dates: make dates readable to a human being" entry:"1693473644" modified:"1693473644" status:"pending" tags:"feat" tags_feat:"x" uuid:"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29"] +--- +time 1693473656 +old [description:"humanize dates: make dates readable to a human being" entry:"1693473644" modified:"1693473644" status:"pending" tags:"feat" tags_feat:"x" uuid:"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29"] +new [description:"humanize dates: make dates readable to a human being" entry:"1693473644" modified:"1693473656" start:"1693473656" status:"pending" tags:"feat" tags_feat:"x" uuid:"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29"] +--- +time 1693475165 +old [description:"humanize dates: make dates readable to a human being" entry:"1693473644" modified:"1693473656" start:"1693473656" status:"pending" tags:"feat" tags_feat:"x" uuid:"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29"] +new [description:"humanize dates: make dates readable to a human being" end:"1693475165" entry:"1693473644" modified:"1693475165" status:"completed" tags:"feat" tags_feat:"x" uuid:"ea4fd6c8-f7d0-4b85-af26-feeb2b196f29"] +--- diff --git a/presets/colors_nojhan.conf b/presets/colors_nojhan.conf index bab4109..ce5d4cc 100644 --- a/presets/colors_nojhan.conf +++ b/presets/colors_nojhan.conf @@ -29,3 +29,5 @@ color.tags.feat=rgb00aaff color.tags.bug=rgb00ccff color.project=rgb8877ff + +color.due=rgbff8888 diff --git a/taskwarrior-deluxe.py b/taskwarrior-deluxe.py index f72c237..166d30a 100755 --- a/taskwarrior-deluxe.py +++ b/taskwarrior-deluxe.py @@ -7,6 +7,8 @@ import json import queue import pathlib import textwrap +import datetime +import humanize import subprocess import rich @@ -69,6 +71,11 @@ class Widget: def rtext(self, val, swatch, prefix = "color.", end="\n"): return rich.text.Text(val, style=self.swatch_of(swatch, val, prefix), end=end) + def rdate(self, date, swatch, prefix = "color.", end="\n"): + dt = datetime.datetime.strptime(date, "%Y%m%dT%H%M%SZ") + hd = humanize.naturaltime(datetime.datetime.now() - dt) + return self.rtext(hd, swatch, prefix, end) + class Tasker(Widget): def __init__(self, config, show_only, order = None, group = None, touched = []): @@ -157,7 +164,10 @@ class task: val = task[key] segment = f"{key}: " if type(val) == str: - segments.append( self.rtext(segment+val, f"{key}") ) + if key in [ "due", "end", "entry", "modified", "scheduled", "start", "until", "wait"]: + segments.append( self.rtext(segment, key) + self.rdate(val, key) ) + else: + segments.append( self.rtext(segment+val, key) ) elif type(val) == list: # FIXME Columns does not fit. # g = Columns([f"+{t}" for t in val], expand = False) @@ -165,14 +175,14 @@ class task: for t in val: lst.append( \ self.rtext(self.tag_icons[0], "tags.ends") + \ - self.rtext(t, f"{key}") + \ + self.rtext(t, key) + \ self.rtext(self.tag_icons[1], "tags.ends") \ ) g = rich.console.Group(*lst, fit = True) # g = rich.console.Group(*[rich.text.Text(f"{self.tag_icons[0]}{t}{self.tag_icons[1]}", style=f"color.{key}") for t in val], fit = True) segments.append(g) else: - segments.append(self.rtext(segment+str(val), f"{key}")) + segments.append(self.rtext(segment+str(val), key)) # FIXME Columns does not fit. # cols = Columns(segments) @@ -312,9 +322,12 @@ class stack: rich.text.Text(":", style="default", end="") + \ self.rtext(desc, "description.long", end="") ) + elif k in [ "due", "end", "entry", "modified", "scheduled", "start", "until", "wait"]: + row.append( self.rdate(val, k) ) + # Strings, but not description. else: - row.append( self.rtext(val, f"{k}") ) + row.append( self.rtext(val, k) ) ##### List keys. ##### elif type(val) == list: # Tags are a special case. @@ -324,16 +337,16 @@ class stack: # FIXME use Columns if/when it does not expand. tags += \ self.rtext(self.tag_icons[0], "tags.ends") + \ - self.rtext(t, f"{k}") + \ + self.rtext(t, k) + \ self.rtext(self.tag_icons[1], "tags.ends") + \ " " row.append( tags ) # List, but not tags. else: - row.append( self.rtext(" ".join(val), f"{k}") ) + row.append( self.rtext(" ".join(val), k) ) ##### Other type of keys. ##### else: - row.append( self.rtext(str(val), f"{k}") ) + row.append( self.rtext(str(val), k) ) else: row.append("") table.add_row(*[t for t in row]) @@ -375,7 +388,7 @@ class sections: if self.grouper.field: swatch = f"{self.grouper.field}.{key}" else: - swatch = f"{key}" + swatch = key val = str(key).upper() sections.append( rich.panel.Panel(self.stacker(groups[key]), title = self.rtext(val, swatch), title_align = "left", expand = True, border_style = self.swatch_of(swatch, val))) return rich.console.Group(*sections) @@ -396,7 +409,7 @@ class sections: row = [] for k in keys: - row.append( rich.panel.Panel(self.stacker(groups[k]), title = self.rtext(k.upper(), f"{k}"), title_align = "left", expand = True, border_style="color.title")) + row.append( rich.panel.Panel(self.stacker(groups[k]), title = self.rtext(k.upper(), k), title_align = "left", expand = True, border_style="color.title")) table.add_row(*row) return table