From 1afa7209675a91875229fbe4ec07f84cbd45bac0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 14 Jun 2016 13:57:25 +1200 Subject: Add per-file editing and completion for td(1) I have "todo", "comp", and "writ". --- bash/bashrc.d/td.bash | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 bash/bashrc.d/td.bash (limited to 'bash') 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 -- cgit v1.2.3