aboutsummaryrefslogblamecommitdiff
path: root/bash/bashrc.d/td.bash
blob: d7200c87770a83f4f2dc01386b91593f90df70f1 (plain) (tree)
1
2
3
4
5
6
7
8
9








                                       



                                                 




                                        
# 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
        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