summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2009-09-07 11:58:23 +0200
committerdakkar <dakkar@thenautilus.net>2009-09-07 11:58:23 +0200
commit772349cd4aa9f92080e26ffcdf8acb33312cc723 (patch)
tree24d48c77018b0425b4b309b009c5d29058acc277
parentfix spacing in translation (diff)
downloadthenautilus-772349cd4aa9f92080e26ffcdf8acb33312cc723.tar.gz
thenautilus-772349cd4aa9f92080e26ffcdf8acb33312cc723.tar.bz2
thenautilus-772349cd4aa9f92080e26ffcdf8acb33312cc723.zip
bash programmable completion for new-* scripts
-rwxr-xr-xnew-doc1
-rwxr-xr-xnew-tag2
-rw-r--r--website.bashcomp19
3 files changed, 21 insertions, 1 deletions
diff --git a/new-doc b/new-doc
index f311766..726d899 100755
--- a/new-doc
+++ b/new-doc
@@ -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
diff --git a/new-tag b/new-tag
index e8b03db..6b999a8 100755
--- a/new-tag
+++ b/new-tag
@@ -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