mirror of
https://github.com/protesilaos/dotfiles.git
synced 2026-09-10 07:16:20 -04:00
Minor refinements to stm
This commit is contained in:
parent
d1746273ac
commit
d576898774
42
bin/bin/stm
42
bin/bin/stm
|
|
@ -31,14 +31,14 @@
|
|||
# * Each task starts with a majuscule
|
||||
# * There is no formal markup, but:
|
||||
# - A task's project/context/category is @context
|
||||
# - Tag[s] are #tag or #tag1,tag2
|
||||
# - Tag[s] are #tag or #tag1 #tag2
|
||||
# - Date is =YYYY-MM-DD
|
||||
# * The task's description always comes first
|
||||
# * Markup is optional and follows in this order: @ # =
|
||||
#
|
||||
# Example of a fully marked-up task:
|
||||
#
|
||||
# Review code @dotfiles #scripts,stm =2019-02-15
|
||||
# Review code @dotfiles #scripts #stm =2019-02-15
|
||||
#
|
||||
# This script is part of my dotfiles:
|
||||
# https://gitlab.com/protesilaos/dotfiles
|
||||
|
|
@ -66,34 +66,40 @@ else
|
|||
fi
|
||||
|
||||
# colour definitions for the output: ANSI sequences
|
||||
my_red='\033[31m'
|
||||
my_green='\033[32m'
|
||||
my_yellow='\033[33m'
|
||||
my_blue='\033[34m'
|
||||
my_red='\033[1;31m'
|
||||
my_green='\033[1;32m'
|
||||
my_yellow='\033[1;33m'
|
||||
my_blue='\033[1;34m'
|
||||
my_magenta='\033[1;35m'
|
||||
my_cyan='\033[1;36m'
|
||||
my_nocol='\033[0m'
|
||||
|
||||
# the line length for folding stm's output
|
||||
stm_fold=80
|
||||
|
||||
# }}}
|
||||
|
||||
# Functions {{{
|
||||
# -------------
|
||||
|
||||
stm_help() {
|
||||
echo -e "${my_cyan}stm${my_nocol} ${my_magenta}[d|due] [e|edit] [l|list] [o|omit] [h|help|-h|--help]${my_nocol}"
|
||||
echo ""
|
||||
echo -e "Run ${my_green}stm${my_nocol} without arguments to print the task list."
|
||||
echo -e "Run ${my_green}stm due${my_nocol} to get only the tasks with a due date."
|
||||
echo -e "Run ${my_green}stm edit${my_nocol} open the task list in your EDITOR."
|
||||
echo -e "Run ${my_green}stm list${my_nocol} <string> to only show tasks that match the given string."
|
||||
echo -e "Run ${my_green}stm omit${my_nocol} <string> to display tasks that **hide** the matching string."
|
||||
echo -e "Run ${my_green}stm help${my_nocol} to get this message."
|
||||
echo -e "The task list is stored in plain text at ${my_blue}$task_list${my_nocol}"
|
||||
echo -e "In case you choose to edit the file, your EDITOR is ${my_blue}$EDITOR${my_nocol}"
|
||||
echo ""
|
||||
echo "This is stm, the Simplistic Task Manager by Protesilaos Stavrou (GPLv3)."
|
||||
echo "My home repo: https://gitlab.com/protesilaos/dotfiles"
|
||||
echo -e "The task list is stored in plain text at ${my_blue}$task_list${my_nocol}."
|
||||
echo -e "In case you choose to edit the file, your EDITOR is ${my_blue}$EDITOR${my_nocol}."
|
||||
echo ""
|
||||
echo "This is STM, the Simplistic Task Manager by Protesilaos Stavrou (GPLv3)."
|
||||
echo "My home repo: https://gitlab.com/protesilaos/dotfiles."
|
||||
echo ""
|
||||
echo "Need ideas for writing good tasks?"
|
||||
echo "See https://protesilaos.com/codelog/2019-01-22-manage-task-list/"
|
||||
echo "See: https://protesilaos.com/codelog/2019-02-17-unix-ways-todo/"
|
||||
}
|
||||
|
||||
# The command that parses the output of the to-do list. To include or
|
||||
|
|
@ -108,7 +114,7 @@ stm_region_parse() {
|
|||
|
||||
# Improve the format of the parsed output. Set the line wrap as well.
|
||||
stm_region_parse_pretty() {
|
||||
sed --follow-symlinks "s/\(^.*\)/* \1/g" | fold -sw 72
|
||||
sed --follow-symlinks "s/\(^.*\)/* \1/g" | fold -sw "$stm_fold"
|
||||
}
|
||||
|
||||
# Provide helpful message on the content of the filtered output.
|
||||
|
|
@ -159,7 +165,7 @@ stm_region="$2"
|
|||
if [ "$#" == 0 ]; then
|
||||
echo "Viewing tasks:"
|
||||
grep -nT '^.*' "$task_list" | \
|
||||
fold -sw 72
|
||||
fold -sw "$stm_fold"
|
||||
else
|
||||
# If there is a first argument, run the appropriate commands.
|
||||
case "$1" in
|
||||
|
|
@ -168,7 +174,7 @@ else
|
|||
grep -e '=[0-9-]*' "$task_list" | \
|
||||
sed --follow-symlinks 's/\(^.*\) =\([0-9-]*\)/\2: \1/g' | \
|
||||
sort -g | \
|
||||
fold -sw 72
|
||||
fold -sw "$stm_fold"
|
||||
;;
|
||||
e|edit)
|
||||
"$EDITOR" "$task_list"
|
||||
|
|
@ -179,14 +185,12 @@ else
|
|||
o|omit)
|
||||
stm_omit
|
||||
;;
|
||||
h|help)
|
||||
h|help|-h|--help)
|
||||
stm_help
|
||||
;;
|
||||
*)
|
||||
echo -e "${my_red}ERROR${my_nocol} Not a valid argument"
|
||||
echo -e "${my_yellow}Try one of those:${my_nocol}"
|
||||
echo ""
|
||||
echo -e "${my_cyan}stm${my_nocol} ${my_magenta}[e|edit] [d|due] [l|list] [o|omit] [h|help]${my_nocol}"
|
||||
echo -e "${my_red}ERROR${my_nocol} ${my_yellow}Not a valid argument.${my_nocol}"
|
||||
echo "Try one of these:"
|
||||
echo ""
|
||||
# Print the help message
|
||||
stm_help
|
||||
|
|
|
|||
Loading…
Reference in a new issue