From 406a519b5d31d90c1f2fda79a2fe6b5abd8f2866 Mon Sep 17 00:00:00 2001 From: q Date: Wed, 6 Sep 2017 20:32:15 +0300 Subject: [PATCH] todo engine --- bin/md-todo | 1 + reporting/md-todo | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 120000 bin/md-todo create mode 100755 reporting/md-todo diff --git a/bin/md-todo b/bin/md-todo new file mode 120000 index 0000000..b186b62 --- /dev/null +++ b/bin/md-todo @@ -0,0 +1 @@ +../reporting/md-todo \ No newline at end of file diff --git a/reporting/md-todo b/reporting/md-todo new file mode 100755 index 0000000..fc8b359 --- /dev/null +++ b/reporting/md-todo @@ -0,0 +1,71 @@ +#!/bin/bash + +function timecolor() { + cat - +} + +function filelist() { + shopt -s nullglob + TODO=(*md) +} + +[[ "$1" = "-h" ]] && { + echo ' +Maintain a set of TODOs in the current folder + +' + exit +} + +. qolop 2>/dev/null || { + function _qCol() { true; } +} +VI=vimd +which $VI &>/dev/null || VI=vim + +while :;do + filelist + files=${#TODO[@]} + { _qCol G; printf '\n# List of TODOs: [unchecked/check boxes/lines]\n'; _qCol z; } + i=0 + EDITFILE="" + for ((n=0;n (q)uit, (n)ew, ## to edit: '; _qCol z; } + read -n ${#i} ANS + ANS="${ANS//[^[:alnum:]]/}" + echo "" + [[ "$ANS" = "q" ]] && exit 0 + [[ "$ANS" = "x" ]] && exit 0 + [[ "$ANS" = "n" ]] && { + ANS="" + { _qCol W; printf '\n> Name (.md will be added): '; _qCol z; } + read NEWFILE + [[ -z $NEWFILE ]] && { continue; } + [[ -f "$NEWFILE".md ]] && { echo File already exists; continue; } + echo "# $NEWFILE" > "$NEWFILE".md || { echo Cannot write file; continue; } + } +done +: