Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posix compliant and show correct number of shown tasks #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions hide
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
#!/bin/bash
#!/bin/sh

CMD=`basename $0`
CMD=$(basename "$0")
ACTION=$1
shift 1
ARGS=$@

# from https://stackoverflow.com/questions/1527049/join-elements-of-an-array
function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
if [ "$ACTION" = "usage" ]; then
echo " hide [TERM...]"
echo " Hide tasks containing ANY of the listed TERM(s):"
echo " $TODO_SH $CMD +foo bar"
echo ""

exit
fi

TERMS=`join_by '\|' $ARGS`
shift 1
ARGS=$*

case $ACTION in
"usage")
echo " hide [TERM...]"
echo " Hide tasks containing ANY of the listed TERM(s):"
echo " $TODO_SH $CMD +foo bar"
echo ""
;;
*)
if [[ -z $TERMS ]]; then
"$TODO_FULL_SH" list
else
GREP_CMD="grep -iv $TERMS"
"$TODO_FULL_SH" list | $GREP_CMD
fi
;;
esac
if [ -z "$ARGS" ]; then
"$TODO_FULL_SH" list
exit
fi

TERMS=$(echo "$ARGS" | sed 's/ \+/ -/')
"$TODO_FULL_SH" list -$TERMS