diff options
author | dakkar <dakkar@thenautilus.net> | 2009-09-07 12:15:06 +0200 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2009-09-07 12:15:06 +0200 |
commit | b9064540b3f335cbb363e65ab0d571ebd77678bf (patch) | |
tree | 32f4ef61980dd45a9d01b32af6ac3d816c365fa9 /website.bashcomp | |
parent | bash programmable completion for new-* scripts (diff) | |
download | thenautilus-b9064540b3f335cbb363e65ab0d571ebd77678bf.tar.gz thenautilus-b9064540b3f335cbb363e65ab0d571ebd77678bf.tar.bz2 thenautilus-b9064540b3f335cbb363e65ab0d571ebd77678bf.zip |
better expansion using pre-defined functions
Diffstat (limited to 'website.bashcomp')
-rw-r--r-- | website.bashcomp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/website.bashcomp b/website.bashcomp index ba04385..04682ed 100644 --- a/website.bashcomp +++ b/website.bashcomp @@ -1,3 +1,22 @@ +_website_filedir() { + local IFS=$'\n' xspec + + _expand || return 0 + + local -a toks + local tmp + + toks=( ${toks[@]-} $( + compgen -d -X "$1" -- "$(quote_readline "$cur")" | { + while read -r tmp; do + [ -n "$tmp" ] && echo "${tmp}/" + done + } + )) + + COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" ) +} + _website_newdoc() { local dir='src' local excl='[._]*' @@ -6,8 +25,11 @@ _website_newdoc() { else excl="@(${excl}|tags)" fi + + local cur="$(_get_cword)" + pushd "$dir" >/dev/null - COMPREPLY=($(compgen -o filenames -o nospace -d -X "$excl" -- "${COMP_WORDS[COMP_CWORD]}" | sed 's,$,/,')) + _website_filedir "$excl" popd >/dev/null } |