Compare commits
2 Commits
archive/co
...
archive/li
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
272cd5e469 | ||
|
|
17658c852d |
8
todo.sh
8
todo.sh
@@ -775,8 +775,12 @@ _list() {
|
|||||||
fi
|
fi
|
||||||
items=$(
|
items=$(
|
||||||
sed = "$src" \
|
sed = "$src" \
|
||||||
| sed "N; s/^/ /; s/ *\(.\{$PADDING,\}\)\n/\1 /" \
|
| sed '''
|
||||||
| grep -v "^[ 0-9]\+ *$"
|
N
|
||||||
|
s/^/ /
|
||||||
|
s/ *\([ 0-9]\{'"$PADDING"',\}\)\n/\1 /
|
||||||
|
/^[ 0-9]\+ *$/d
|
||||||
|
'''
|
||||||
)
|
)
|
||||||
if [ "${filter_command}" ]; then
|
if [ "${filter_command}" ]; then
|
||||||
filtered_items=$(echo -n "$items" | eval "${filter_command}")
|
filtered_items=$(echo -n "$items" | eval "${filter_command}")
|
||||||
|
|||||||
@@ -38,28 +38,20 @@ _todo()
|
|||||||
+*) completions=$(TODOTXT_VERBOSE=0 todo.sh command listproj);;
|
+*) completions=$(TODOTXT_VERBOSE=0 todo.sh command listproj);;
|
||||||
@*) completions=$(TODOTXT_VERBOSE=0 todo.sh command listcon);;
|
@*) completions=$(TODOTXT_VERBOSE=0 todo.sh command listcon);;
|
||||||
*) if [[ "$cur" =~ ^[0-9]+$ ]]; then
|
*) 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
|
# Remove the (padded) task number; we prepend the
|
||||||
# user-provided $cur instead.
|
# user-provided $cur.
|
||||||
# Remove the timestamp prepended by the -t option,
|
item=${item#* }
|
||||||
# and the done date (for done tasks); there's no
|
|
||||||
# todo.txt option for that yet.
|
# Remove the timestamp prepended by the -t option;
|
||||||
# But keep priority and "x"; they're short and may
|
# there's no todo.txt option for that yet.
|
||||||
# provide useful context.
|
item=${item#[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] }
|
||||||
# Remove any trailing whitespace; the Bash
|
|
||||||
# completion inserts a trailing space itself.
|
|
||||||
# Finally, limit the output to a single line just as
|
|
||||||
# a safety check of the ls action output.
|
|
||||||
local todo=$( \
|
|
||||||
TODOTXT_VERBOSE=0 todo.sh -@ -+ -p -x command ls "^ *${cur} " | \
|
|
||||||
sed -e 's/^ *[0-9]\+ //' -e 's/\((.) \)[0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} /\1/' \
|
|
||||||
-e 's/\([xX] \)\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{1,2\}/\1/' \
|
|
||||||
-e 's/[[:space:]]*$//' \
|
|
||||||
-e '1q' \
|
|
||||||
)
|
|
||||||
# Append task text as a shell comment. This
|
# Append task text as a shell comment. This
|
||||||
# completion can be a safety check before a
|
# completion can be a safety check before a
|
||||||
# destructive todo.txt operation.
|
# destructive todo.txt operation.
|
||||||
[ "$todo" ] && COMPREPLY[0]="$cur # $todo"
|
[ "$item" ] && COMPREPLY[0]="$cur # $item"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user