Compare commits
1 Commits
archive/to
...
archive/bu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea0e7c7b25 |
2
Makefile
2
Makefile
@@ -13,7 +13,7 @@ VERSION-FILE: .FORCE-VERSION-FILE
|
|||||||
todo.sh: VERSION-FILE
|
todo.sh: VERSION-FILE
|
||||||
|
|
||||||
# For packaging
|
# For packaging
|
||||||
DISTFILES := todo.cfg todo_completion
|
DISTFILES := todo.cfg
|
||||||
|
|
||||||
DISTNAME=todo.txt_cli-$(VERSION)
|
DISTNAME=todo.txt_cli-$(VERSION)
|
||||||
dist: $(DISTFILES) todo.sh
|
dist: $(DISTFILES) todo.sh
|
||||||
|
|||||||
@@ -73,6 +73,29 @@ TODO: 1 of 3 tasks shown
|
|||||||
TODO: 1 of 3 tasks shown
|
TODO: 1 of 3 tasks shown
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
#
|
||||||
|
# check negative filtering via -TERM
|
||||||
|
#
|
||||||
|
test_todo_session 'checking negative filtering via -TERM' <<EOF
|
||||||
|
>>> todo.sh ls -second
|
||||||
|
2 aaa zzz this line should be first.
|
||||||
|
1 ccc xxx this line should be third.
|
||||||
|
--
|
||||||
|
TODO: 2 of 3 tasks shown
|
||||||
|
|
||||||
|
>>> todo.sh ls "-should be f"
|
||||||
|
3 bbb yyy this line should be second.
|
||||||
|
1 ccc xxx this line should be third.
|
||||||
|
--
|
||||||
|
TODO: 2 of 3 tasks shown
|
||||||
|
|
||||||
|
>>> todo.sh ls "- zzz"
|
||||||
|
3 bbb yyy this line should be second.
|
||||||
|
1 ccc xxx this line should be third.
|
||||||
|
--
|
||||||
|
TODO: 2 of 3 tasks shown
|
||||||
|
EOF
|
||||||
|
|
||||||
#
|
#
|
||||||
# check the filtering of TERM with regexp
|
# check the filtering of TERM with regexp
|
||||||
#
|
#
|
||||||
|
|||||||
2
todo.sh
2
todo.sh
@@ -688,7 +688,7 @@ filtercommand()
|
|||||||
## $search_term
|
## $search_term
|
||||||
#
|
#
|
||||||
## Remove the first character (-) before adding to our filter command
|
## Remove the first character (-) before adding to our filter command
|
||||||
filter="${filter:-}${filter:+ | }grep -v -i '$(shellquote "${search_term:1}")'"
|
filter="${filter:-}${filter:+ | }grep -v -i $(shellquote "${search_term:1}")"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
#!/bin/bash source-this-script
|
|
||||||
[ "$BASH_VERSION" ] || return
|
|
||||||
|
|
||||||
_todo()
|
|
||||||
{
|
|
||||||
local cur prev opts
|
|
||||||
COMPREPLY=()
|
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
||||||
|
|
||||||
local -r OPTS="-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x"
|
|
||||||
local -r COMMANDS="\
|
|
||||||
add a addto addm append app archive command del \
|
|
||||||
rm depri dp do help list ls listall lsa listcon \
|
|
||||||
lsc listfile lf listpri lsp listproj lsprj move \
|
|
||||||
mv prepend prep pri p replace report shorthelp"
|
|
||||||
|
|
||||||
# Add custom commands from add-ons, if installed.
|
|
||||||
# TODO: Filter for executable flag of files found in $TODO_ACTIONS_DIR.
|
|
||||||
local allCommands="$COMMANDS $('ls' "${TODO_ACTIONS_DIR:-$HOME/.todo.actions.d}/" 2>/dev/null)"
|
|
||||||
|
|
||||||
local completions
|
|
||||||
if [ $COMP_CWORD -eq 1 ]; then
|
|
||||||
completions="$allCommands $OPTS"
|
|
||||||
else
|
|
||||||
case "$prev" in
|
|
||||||
command)
|
|
||||||
completions=$COMMANDS;;
|
|
||||||
-*) completions="$allCommands $OPTS";;
|
|
||||||
*) case "$cur" in
|
|
||||||
+*) completions=$(TODOTXT_VERBOSE=0 todo.sh command listproj);;
|
|
||||||
@*) completions=$(TODOTXT_VERBOSE=0 todo.sh command listcon);;
|
|
||||||
*) if [[ "$cur" =~ ^[0-9]+$ ]]; then
|
|
||||||
local item=$(TODOTXT_VERBOSE=0 todo.sh -@ -+ -p -x command ls "^ *${cur} " | head -n 1)
|
|
||||||
|
|
||||||
# Remove the (padded) task number; we prepend the
|
|
||||||
# user-provided $cur.
|
|
||||||
item=${item#* }
|
|
||||||
|
|
||||||
# Remove the timestamp prepended by the -t option;
|
|
||||||
# there's no todo.txt option for that yet.
|
|
||||||
item=${item#[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] }
|
|
||||||
|
|
||||||
# Append task text as a shell comment. This
|
|
||||||
# completion can be a safety check before a
|
|
||||||
# destructive todo.txt operation.
|
|
||||||
[ "$item" ] && COMPREPLY[0]="$cur # $item"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
COMPREPLY=( $( compgen -W "$completions" -- $cur ))
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
complete -F _todo todo.sh
|
|
||||||
# If you define an alias (e.g. "t") to todo.sh, you need to explicitly enable
|
|
||||||
# completion for it, too:
|
|
||||||
#complete -F _todo t
|
|
||||||
Reference in New Issue
Block a user