aboutsummaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
Diffstat (limited to 'etc')
-rw-r--r--etc/Makefile.am17
-rw-r--r--etc/compl.sh82
2 files changed, 86 insertions, 13 deletions
diff --git a/etc/Makefile.am b/etc/Makefile.am
index 6ef5e1a..a42deb2 100644
--- a/etc/Makefile.am
+++ b/etc/Makefile.am
@@ -37,11 +37,9 @@ if SPLIT_FORMATS
SUFFIXES += .forlan .fln
.fln.forlan:
$(AM_V_GEN)$(abs_builddir)/flncat $< default.fln > $@
-formatdir = @FORMATDIR@
FORMATFILES = $(FLNFILES:.fln=.forlan)
FORMATNAME = $${command}
else
-formatdir = @FORMATDIR@
FORMATFILES = eclat.forlan
eclat.forlan: $(FLNFILES) default.fln
$(AM_V_GEN)(cd $(srcdir); $(abs_builddir)/flncat $(FLNFILES) default.fln) > eclat.forlan
@@ -52,21 +50,14 @@ noinst_SCRIPTS=eclat.conf $(FORMATFILES)
CLEANFILES=eclat.conf $(FORMATFILES)
.cfin.conf:
- $(AM_V_GEN)sed 's^FORMATDIR^$(formatdir)^;s^FORMATNAME^$(FORMATNAME)^' $< > $@
+ $(AM_V_GEN)sed 's^FORMATDIR^$(pkgdatadir)^;s^FORMATNAME^$(FORMATNAME)^' $< > $@
-install-formats: $(FORMATFILES)
- ${INSTALL} -d $(DESTDIR)$(formatdir); \
- for file in $(FORMATFILES); do \
- ${INSTALL} -m 644 $$file $(DESTDIR)$(formatdir)/$$file; \
- done
+pkgdata_DATA = $(FORMATFILES)
+dist_pkgdata_DATA = compl.sh
install-data-local:
@test -z "$(DESTDIR)$(sysconfdir)" || $(mkdir_p) "$(DESTDIR)$(sysconfdir)"
@if [ -r $(DESTDIR)$(sysconfdir)/eclat.conf ]; then :; \
- else ${INSTALL} -m 644 $(top_srcdir)/etc/eclat.conf \
+ else ${INSTALL} -m 644 $(top_builddir)/etc/eclat.conf \
$(DESTDIR)$(sysconfdir)/eclat.conf; \
- ${INSTALL} -d $(DESTDIR)$(formatdir); \
- for file in $(FORMATFILES); do \
- ${INSTALL} -m 644 $$file $(DESTDIR)$(formatdir)/$$file; \
- done; \
fi
diff --git a/etc/compl.sh b/etc/compl.sh
new file mode 100644
index 0000000..d56f1a3
--- /dev/null
+++ b/etc/compl.sh
@@ -0,0 +1,82 @@
+#! /bin/bash
+# Bash completion setup for Eclat commands.
+# Copyright (C) 2012 Sergey Poznyakoff
+#
+# Eclat is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Eclat is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Eclat. If not, see <http://www.gnu.org/licenses/>.
+
+comp_eclat() {
+ # Obtain a list of command line options. Each option occupies
+ # a single line and is followed by an equals sign if it takes
+ # an argument.
+ local optlist=$(eclat --usage|sed '1s/^[^[]*//' |
+ tr -d '\n' |
+ tr -s ' ' |
+ sed 's/\] \[/:/g;' |
+ tr -d '[]' |
+ awk -F: '
+ function optproc(s, i,n,a) {
+ if (match(s, /^-[a-zA-Z][a-zA-Z]/)) {
+ n = split(s, a, "");
+ for (i = 2; i <= n; i++)
+ print "-" a[i];
+ } else if (match(s, /^-[a-zA-Z] ./))
+ print substr(s,1,2) "=";
+ else {
+ if (match(s, /=/)) {
+ opt="="
+ sub(/=.*/,"",s)
+ } else
+ opt=""
+ n = split(s, a, " ");
+ for (i = 1; i <= n; i++) {
+ sub(/,$/,"",a[i])
+ print a[i] opt
+ }
+ }
+ }
+ { for (i = 1; i < NF; i++) optproc($i) }')
+
+ # Bail out if we're sitting on a word starting with a dash, i.e.
+ # an option. Otherwise, make sure no command appears in the command
+ # line to the left of the current word. If not, we're trying to
+ # complete a command, so proceed safely.
+ COMPREPLY=()
+ local opt arg=${COMP_WORDS[$COMP_CWORD]}
+ case $arg in
+ -*) return
+ esac
+ for i in $(seq $(($COMP_CWORD - 1)) -1 1)
+ do
+ opt=${COMP_WORDS[$i]}
+ case $opt in
+ -*) if test -n "$arg"; then
+ if echo "$optlist" | grep -q "^$opt.*="; then
+ test $i -eq $(($COMP_CWORD - 1)) && return
+ arg=
+ else
+ return
+ fi
+ fi
+ ;;
+ *) if test -n "$arg" && test $i -lt $(($COMP_CWORD - 1)); then
+ return
+ else
+ arg=$opt
+ fi
+ esac
+ done
+ # Finally, find matching commands.
+ COMPREPLY=( $(eclat --match-commands ${COMP_WORDS[$COMP_CWORD]}) )
+}
+complete -F comp_eclat eclat

Return to:

Send suggestions and report system problems to the System administrator.