aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/td.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/bashrc.d/td.bash')
-rw-r--r--bash/bashrc.d/td.bash18
1 files changed, 18 insertions, 0 deletions
diff --git a/bash/bashrc.d/td.bash b/bash/bashrc.d/td.bash
new file mode 100644
index 00000000..825b5c54
--- /dev/null
+++ b/bash/bashrc.d/td.bash
@@ -0,0 +1,18 @@
+# Complete filenames for td(1)
+_td() {
+ local dir
+ dir=${TODO_DIR:-$HOME/Todo}
+ while IFS= read -d '' -r fn ; do
+ COMPREPLY[${#COMPREPLY[@]}]=$fn
+ done < <(
+ shopt -s extglob nullglob
+ shopt -u dotglob
+ declare -a fns
+ cd -- "$dir" || exit
+ fns=(*)
+ ((${#fns[@]})) || exit
+ printf '%s\0' "${fns[@]##$dir/}"
+ )
+ return
+}
+complete -F _td td