summaryrefslogtreecommitdiff
path: root/website.bashcomp
diff options
context:
space:
mode:
Diffstat (limited to 'website.bashcomp')
-rw-r--r--website.bashcomp67
1 files changed, 58 insertions, 9 deletions
diff --git a/website.bashcomp b/website.bashcomp
index 04682ed..b1e7889 100644
--- a/website.bashcomp
+++ b/website.bashcomp
@@ -1,33 +1,82 @@
_website_filedir() {
- local IFS=$'\n' xspec
+ local IFS=$'\n'
- _expand || return 0
+ _tilde "$cur" || return 0
local -a toks
- local tmp
-
+ local quoted tmp
+
+ _quote_readline_by_ref "$cur" quoted
toks=( ${toks[@]-} $(
- compgen -d -X "$1" -- "$(quote_readline "$cur")" | {
+ compgen -d -X "$1" -- "$quoted" | {
while read -r tmp; do
- [ -n "$tmp" ] && echo "${tmp}/"
+ 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='[._]*'
- if [[ "$COMP_CWORD" -gt 1 ]]; then
+ 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
- local cur="$(_get_cword)"
-
pushd "$dir" >/dev/null
_website_filedir "$excl"
popd >/dev/null