From b4aaba8387086c0994244183ff108747f1af53ca Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Mon, 9 Jan 2012 15:41:04 +0100 Subject: [PATCH] Strip trailing whitespace when completing tasks. --- todo_completion | 3 +++ 1 file changed, 3 insertions(+) diff --git a/todo_completion b/todo_completion index 1a62c5c..faf91a7 100644 --- a/todo_completion +++ b/todo_completion @@ -45,12 +45,15 @@ _todo() # todo.txt option for that yet. # But keep priority and "x"; they're short and may # provide useful context. + # 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