From 2c0f6f7c6b34107d828d30e11d116ec24c934b1b Mon Sep 17 00:00:00 2001 From: David Moc Date: Sun, 17 May 2026 01:35:00 +0200 Subject: Updated the readme and added a manpage and bash completion. Signed-off-by: David Moc --- tasker.bash | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 tasker.bash (limited to 'tasker.bash') diff --git a/tasker.bash b/tasker.bash new file mode 100644 index 0000000..6b13ae8 --- /dev/null +++ b/tasker.bash @@ -0,0 +1,90 @@ +_tasker_task_dirs() { + local root d name + if [[ -d "$PWD/tasks" ]]; then + root="$PWD/tasks" + else + root="$PWD" + fi + + shopt -s nullglob + for d in "$root"/*/; do + name="${d%/}" + name="${name##*/}" + if [[ "$name" =~ ^[0-9]{2}-[0-9]{2}-[0-9]{2}\ [0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?$ ]]; then + printf '%s\n' "$name" + fi + done +} + +_tasker_completion() { + local cur prev words cword subcommand + COMPREPLY=() + + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + local commands="new list set delete" + + subcommand="" + for word in "${COMP_WORDS[@]:1}"; do + case "$word" in + new|list|set|delete) + subcommand="$word" + break + ;; + esac + done + + if [[ -z "$subcommand" ]]; then + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + return 0 + fi + + case "$subcommand" in + new) + case "$prev" in + -p|-d) + return 0 + ;; + esac + COMPREPLY=( $(compgen -W "-p -d" -- "$cur") ) + ;; + + list) + case "$prev" in + -s|--status) + COMPREPLY=( $(compgen -W "OPEN IN_PROGRESS CLOSED" -- "$cur") ) + return 0 + ;; + -p|--priority|--min-priority|-c|--contains) + return 0 + ;; + esac + COMPREPLY=( $(compgen -W "-s --status -p --priority --min-priority -c --contains" -- "$cur") ) + ;; + + set) + case "$prev" in + -s|--status) + COMPREPLY=( $(compgen -W "OPEN IN_PROGRESS CLOSED" -- "$cur") ) + return 0 + ;; + -n|--name|-p|--priority|-d|--desc) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $(compgen -W "-n --name -s --status -p --priority -d --desc" -- "$cur") ) + else + COMPREPLY=( $(compgen -W "$(_tasker_task_dirs)" -- "$cur") ) + fi + ;; + + delete) + COMPREPLY=( $(compgen -W "$(_tasker_task_dirs)" -- "$cur") ) + ;; + esac +} + +complete -F _tasker_completion tasker -- cgit v1.2.3