dotfiles/config/todo/actions/@ (view raw)
| 1 | #!/usr/bin/env bash |
| 2 | export TODOTXT_VERBOSE=0 |
| 3 | |
| 4 | action=$1 |
| 5 | shift |
| 6 | |
| 7 | if [[ $action == "usage" ]]; then |
| 8 | echo "@ [context]" |
| 9 | echo " Lists all tasks with the given context." |
| 10 | echo " If no context is given, lists all tasks categorized by their context." |
| 11 | echo " If task has @someday, it won't be listed." |
| 12 | exit 0 |
| 13 | fi |
| 14 | |
| 15 | CONTEXTS=$(grep -o '[^ ]*@[^ ]\+' "$TODO_FILE" | grep '^@' | sort -u | sed 's/^@//g' ) |
| 16 | for context in $CONTEXTS ; do |
| 17 | if [[ $context == "someday" ]]; then |
| 18 | continue |
| 19 | fi |
| 20 | |
| 21 | CONTEXT_LIST=$(_list "$TODO_FILE" "@$context\b" "$@" | sed 's/\ *@[a-zA-Z0-9._\-]*\ */ /g') |
| 22 | if [[ -n "${CONTEXT_LIST}" ]]; then |
| 23 | echo -e "--@${context}" |
| 24 | echo "${CONTEXT_LIST}" | eval "$TODOTXT_FINAL_FILTER" |
| 25 | fi |
| 26 | done |