aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-06-14 13:57:25 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-06-14 13:57:25 +1200
commit1afa7209675a91875229fbe4ec07f84cbd45bac0 (patch)
tree23de16888a5c0e35cd86633bd70aa32c013f212b /bash
parentStrip trailing newline (diff)
downloaddotfiles-1afa7209675a91875229fbe4ec07f84cbd45bac0.tar.gz
dotfiles-1afa7209675a91875229fbe4ec07f84cbd45bac0.zip
Add per-file editing and completion for td(1)
I have "todo", "comp", and "writ".
Diffstat (limited to '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