#!/usr/bin/env bash # * tt - time scripts, see below # ** PREAMBLE # Customise as needed; consider keeping as a git checkout for merging updates. # Uses hledger, bash, python, a few other unix tools. # wakelog is a script grepping system logs for sleep/wake events; provide it or comment it. # See also: justfile, an alternative. ## #!/usr/bin/env -S osh # -*- sh -*- # or osh - more powerful, less tool support ## shopt -s -errexit strict:all 2>/dev/null || set -e # shellcheck shell=bash disable=SC2096 disable=SC2317 set -e rg="rg -IN --sort=path" date=$(if [ "$(builtin type -p gdate)" ]; then echo gdate; else echo date; fi) sed=$(if [ "$(builtin type -p gsed)" ]; then echo gsed; else echo sed; fi) stat=$(if [ "$(builtin type -p gstat)" ]; then echo gstat; else echo stat; fi) help() { # show this help cat <>"$TIMELOG" } # Budget reports. cf status() budgets() { # show monthly time budget performance this year x --budget=daily -M -p jan..tomorrow "$@" } budgetsy() { # show monthly time budget performance this year, vertically # cf status() y --budget=daily -M -p jan..tomorrow "$@" } # dedicated commands needed to set proper week start date for simple headings: budgetsw() { # show weekly time budget performance this year # cf status() y --budget=daily -W -p 3/27..tomorrow "$@" } budgetswx() { # show weekly time budget performance this year, horizontally # cf status() x --budget=daily -W -p 3/27..tomorrow "$@" } # ** END if [[ $# -eq 0 ]]; then help # no args shows help elif declare -f "$1" > /dev/null; then "$@"; # arg 1 selects a function above else hledger -f "$TIMELOG" "$@"; fi # or fall through to hledger exit