aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/td.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-07-30 01:17:09 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-07-30 02:09:30 +1200
commit4cbbd121c012b3962f12fdff0f1820c3b8636a44 (patch)
tree00149270df365ed0b7a1b9e9f4922fe7d5a80eb3 /bash/bash_completion.d/td.bash
parentChange ca from Bash func to sh script (diff)
downloaddotfiles-4cbbd121c012b3962f12fdff0f1820c3b8636a44.tar.gz
dotfiles-4cbbd121c012b3962f12fdff0f1820c3b8636a44.zip
Move bash completion setup into separate dir
Diffstat (limited to 'bash/bash_completion.d/td.bash')
-rw-r--r--bash/bash_completion.d/td.bash18
1 files changed, 18 insertions, 0 deletions
diff --git a/bash/bash_completion.d/td.bash b/bash/bash_completion.d/td.bash
new file mode 100644
index 00000000..ffb9c973
--- /dev/null
+++ b/bash/bash_completion.d/td.bash
@@ -0,0 +1,18 @@
+# Complete filenames for td(1)
+_td() {
+ local dir
+ dir=${TODO_DIR:-"$HOME"/Todo}
+ while IFS= read -rd '' fn ; do
+ COMPREPLY[${#COMPREPLY[@]}]=$fn
+ done < <(
+ shopt -s extglob nullglob
+ shopt -u dotglob
+ local -a fns
+ fns=("$dir"/"${COMP_WORDS[COMP_CWORD]}"*)
+ fns=("${fns[@]#"$dir"/}")
+ ((${#fns[@]})) || exit 1
+ printf '%s\0' "${fns[@]##"$dir"/}"
+ )
+ return
+}
+complete -F _td td