_website_filedir() { local IFS=$'\n' _tilde "$cur" || return 0 local -a toks local quoted tmp _quote_readline_by_ref "$cur" quoted toks=( ${toks[@]-} $( compgen -d -X "$1" -- "$quoted" | { while read -r tmp; do printf '%s/\n' $tmp done } )) [ ${#toks[@]} -ne 0 ] && compopt -o filenames COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" ) } _website_kinds() { local IFS=$'\n' _tilde "$cur" || return 0 local -a toks local quoted tmp _quote_readline_by_ref "$cur" quoted pushd templates >/dev/null toks=( ${toks[@]-} $( compgen -f -X "!du2html-*.xsl" -- "$quoted" | { while read -r tmp; do tmp="${tmp#du2html-}" tmp="${tmp%.xsl}" printf '%s\n' $tmp done } )) popd >/dev/null [ ${#toks[@]} -ne 0 ] && compopt -o filenames COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" ) } _website_newdoc() { local dir='src' local excl='[._]*' local cur prev _get_comp_words_by_ref cur prev if [[ $prev == -k ]]; then _website_kinds return 0 fi local offset i offset=1 for (( i=1; i <= COMP_CWORD; i++ )); do if [[ "${COMP_WORDS[i]}" == -k ]]; then i=$(( i + 1 )) continue fi if [[ "${COMP_WORDS[i]}" != -* ]]; then offset=$i break fi done if [[ $(( $COMP_CWORD - $offset )) -gt 0 ]]; then dir="${dir}/tags" else excl="@(${excl}|tags)" fi pushd "$dir" >/dev/null _website_filedir "$excl" popd >/dev/null } _website_newtag() { false } complete -o filenames -o nospace -F _website_newdoc ./new-doc complete -o filenames -o nospace -F _website_newtag ./new-tag