diff options
author | dakkar <dakkar@thenautilus.net> | 2009-09-07 11:58:23 +0200 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2009-09-07 11:58:23 +0200 |
commit | 772349cd4aa9f92080e26ffcdf8acb33312cc723 (patch) | |
tree | 24d48c77018b0425b4b309b009c5d29058acc277 | |
parent | fix spacing in translation (diff) | |
download | thenautilus-772349cd4aa9f92080e26ffcdf8acb33312cc723.tar.gz thenautilus-772349cd4aa9f92080e26ffcdf8acb33312cc723.tar.bz2 thenautilus-772349cd4aa9f92080e26ffcdf8acb33312cc723.zip |
bash programmable completion for new-* scripts
-rwxr-xr-x | new-doc | 1 | ||||
-rwxr-xr-x | new-tag | 2 | ||||
-rw-r--r-- | website.bashcomp | 19 |
3 files changed, 21 insertions, 1 deletions
@@ -55,6 +55,7 @@ EOF if [[ ${#tags[@]} -gt 0 ]]; then i=0 for tag in "${tags[@]}"; do + tag="${tag%/}" if [[ $i -eq 0 ]]; then echo -n ':tags: ' else @@ -23,7 +23,7 @@ now="$(TZ=UTC date +'%F %T')" langs="${LANGS:-en it}" for tag in "$@"; do - + tag="${tag%/}" if [[ -d "$tag" ]]; then >&2 echo "tag \"$tag\" already exists" else diff --git a/website.bashcomp b/website.bashcomp new file mode 100644 index 0000000..ba04385 --- /dev/null +++ b/website.bashcomp @@ -0,0 +1,19 @@ +_website_newdoc() { + local dir='src' + local excl='[._]*' + if [[ "$COMP_CWORD" -gt 1 ]]; then + dir="${dir}/tags" + else + excl="@(${excl}|tags)" + fi + pushd "$dir" >/dev/null + COMPREPLY=($(compgen -o filenames -o nospace -d -X "$excl" -- "${COMP_WORDS[COMP_CWORD]}" | sed 's,$,/,')) + 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 |