commit 03ae675ca7185cf975d2f7962791519e8478e2b0
Author: Anton Konyahin <me@konyahin.xyz>
Date: Wed, 13 Mar 2024 22:03:41 +0300
todotxt: initial commit
Diffstat:
7 files changed, 99 insertions(+), 0 deletions(-)
diff --git a/LICENSE b/LICENSE
@@ -0,0 +1,21 @@
+MIT/X Consortium License
+
+© 2024 Anton Konyahin me@konyahin.xyz
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/TODO b/TODO
@@ -0,0 +1 @@
+2024-03-13 add script for help generation from source
diff --git a/todotxt/help b/todotxt/help
@@ -0,0 +1,12 @@
+todo - mode for work with todo.txt[1] files
+
+Shortcuts:
+ ;h - show this help
+ ;n - add new task
+ ;s - sort tasks in file
+ ;t - move task in todo list
+ ;m - move task in maybe list
+ ;a - move task in active list
+ ;d - mark task as done
+
+1: https://github.com/todotxt/todo.txt
diff --git a/todotxt/nvi b/todotxt/nvi
@@ -0,0 +1 @@
+nvi -c "source ./todotxt" test
diff --git a/todotxt/test b/todotxt/test
@@ -0,0 +1,5 @@
+2023-03-13 some todo
+2023-02-10 another todo
+x completed task
+todo without date
+todo with tag +todo
diff --git a/todotxt/todotxt b/todotxt/todotxt
@@ -0,0 +1,9 @@
+map ;h :!$PAGER ./help
+
+map ;n 0:r!date +\%Y-\%m-\%dA
+map ;s :%!sort
+
+map ;t :.!./ttxt todo
+map ;m :.!./ttxt maybe
+map ;a :.!./ttxt active
+map ;d :.!./ttxt done
diff --git a/todotxt/ttxt b/todotxt/ttxt
@@ -0,0 +1,50 @@
+#!/usr/bin/env sh
+
+set -eu
+
+if [ "$#" -lt 1 ]; then
+ printf "Usage: ttxt <command>\nYour todo line should be send to stdin of ttxt.\n"
+ exit 1
+fi
+
+# remove pattern string
+remove () {
+ echo "$2" | sed "s/ $1//"
+}
+
+# remove all lists from string
+remove_lists () {
+ lists="+maybe +todo +active"
+ line="$1"
+
+ for list in $lists
+ do
+ line=$(remove "$list" "$line")
+ done
+
+ echo "$line"
+}
+
+read -r LINE
+case "$1" in
+ todo)
+ LINE=$(remove_lists "$LINE")
+ echo "$LINE +todo"
+ ;;
+ maybe)
+ LINE=$(remove_lists "$LINE")
+ echo "$LINE +maybe"
+ ;;
+ active)
+ LINE=$(remove_lists "$LINE")
+ echo "$LINE +active"
+ ;;
+ done)
+ echo "x $(date +%Y-%m-%d) $LINE"
+ ;;
+ *)
+ echo "Unknown command: $1"
+ exit 1
+ ;;
+esac
+