From d00c86a97392043d66574b8c903f58c04db301ca Mon Sep 17 00:00:00 2001 From: Alen Date: Wed, 13 Sep 2023 01:52:41 +0400 Subject: Add todo.txt config --- dot_local/bin/executable_todosort.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 dot_local/bin/executable_todosort.py (limited to 'dot_local/bin') diff --git a/dot_local/bin/executable_todosort.py b/dot_local/bin/executable_todosort.py new file mode 100644 index 0000000..2f75ee9 --- /dev/null +++ b/dot_local/bin/executable_todosort.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import sys + + +def main() -> None: + priority_words = {w.lower() for w in sys.argv[1:]} + lines = [] + for line in sys.stdin.readlines(): + words = line.split() + if words[1].startswith('(') and words[1].endswith(')'): + priority = words[1] + else: + priority = '(X)' + for due in words: + if due.startswith('due:'): + break + else: + due = 'due:3000-01-01' + has_priority_words = not any(w.lstrip('+#@').lower() in priority_words for w in words) + lines.append((priority, has_priority_words, due, line)) + print(''.join(l for *_, l in sorted(lines))) + + +if __name__ == '__main__': + main() -- cgit 1.4.1-2-gfad0