logo

utils

~/.local/bin tools and git-hooks
commit: a369170204898da2a974dbf68511f08fe39d53bb
parent: 9f30dcacf0c56b0a19615ad11e99d6450d919de3
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue,  8 Jan 2019 06:07:11 +0100

bin/timey-whyme.sh: Move to groff-formatting, fix against shellcheck

Diffstat:

Mbin/timey-whyme.sh61+++++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 43 insertions(+), 18 deletions(-)

diff --git a/bin/timey-whyme.sh b/bin/timey-whyme.sh @@ -1,21 +1,19 @@ #!/bin/sh # Copyright CC-BY-SA-4.0 2017-2019 Haelwenn (lanodan) Monnier <contact@hacktivis.me> - - xdd="${XDG_DATA_DIR:-$HOME/.local/share}/timey-whyme" +xdd="${XDG_DATA_DIR:-$HOME/.local/share}/timey-whyme" today="$(date --date=now +%Y-%m-%d)" later="$(date --date=+7days +%Y-%m-%d)" - form='column -s, -o  -t' usage() { - echo $0' [t…|c…|h…] + echo "$0"' [t…|c…|h…] c…: show calendar t…: show todo h…: this help' echo ' Files used: - • '$xdd'/calendar.csv - • '$xdd'/todo.csv' + • '"$xdd"'/calendar.csv + • '"$xdd"'/todo.csv' echo ' Environment used: @@ -23,28 +21,55 @@ Environment used: } die() { - echo $1 + echo "$1" exit } verify_xxd() { - [ -e "${xdd}/${1}" ] || die "Please create a file a the following, see examples for help: ${xdd}/${1}" + [ -e "${xdd}/${1}" ] || die "Please create the following file, see examples for help: ${xdd}/${1}" } -todo() { - verify_xxd todo.csv - echo ",0,### To Do, , ### -${today},###, Now +7 days, ### -${later},###, Later,### -$(cut -d '#' -f -1 "$xdd/todo.csv" | grep -v '^$')" | sort -n | $form +todo_gen() { + echo \ +'.color 1 +.TS +llll. +.TH +Deadline Nice Description Location +.TB +_' + ( + cut -d '#' -f -1 "$xdd/todo.csv" | grep -v '^$' + echo "${today},\m[blue],Now +7days" + echo "${later},\m[],Later" + ) | sort -n | tr ',' ' ' + echo '.TE' +} + +calendar_gen() { + echo \ +'.color 1 +.TS +llll. +.TH +Start End Description Location +.TB +_' + ( + cut -d '#' -f -1 "$xdd/calendar.csv" | grep -v '^$' + echo "${today},\m[blue],Now +7days" + echo "${later},\m[],Later" + ) | sort -n | tr ',' ' ' + echo '.TE' } calendar() { verify_xxd calendar.csv - echo "0000-00-00,###, Calendar, ### -${today},###, Now +7 days, ### -${later},###, Later,### -$(cut -d '#' -f -1 "$xdd/calendar.csv" | grep -v '^$')" | sort -n | $form + calendar_gen | groff -t -Dutf-8 -Tutf8 | grep -v '^$' +} +todo() { + verify_xxd todo.csv + todo_gen | groff -t -Dutf-8 -Tutf8 | grep -v '^$' } case "$1" in