aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-11-10 01:48:51 +0100
committerMattias Andrée <maandree@operamail.com>2015-11-10 01:48:51 +0100
commitc3943bcc6e0b7ca4b65f9fc94a25ea7cd73527b7 (patch)
tree5e168d1985852a1d731c5de532b0e0bdd81b2aea
parentupdate doc (diff)
downloadsleep-until-c3943bcc6e0b7ca4b65f9fc94a25ea7cd73527b7.tar.gz
sleep-until-c3943bcc6e0b7ca4b65f9fc94a25ea7cd73527b7.tar.bz2
sleep-until-c3943bcc6e0b7ca4b65f9fc94a25ea7cd73527b7.tar.xz
add autocompletion
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--Makefile62
-rw-r--r--src/completion11
2 files changed, 68 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 1accbd7..35addb0 100644
--- a/Makefile
+++ b/Makefile
@@ -52,10 +52,10 @@ FLAGS = $(WARN) $(STD) $(OPTIMISE) -D_POSIX_C_SOURCE=199309L
# Build rules.
.PHONY: default
-default: command info
+default: command info shell
.PHONY: all
-all: command doc
+all: command doc shell
# Build rules for the command.
@@ -71,7 +71,7 @@ obj/sleep-until.o: obj/sleep-until.c
obj/sleep-until.c: src/sleep-until.c
@mkdir -p obj
- gpp -s '$$' -i $< -o $@
+ $(GPP) -s '$$' -i $< -o $@
# Build rules for documentation.
@@ -106,14 +106,37 @@ bin/%.ps: doc/info/%.texinfo doc/info/fdl.texinfo
cd obj/ps ; yes X | texi2pdf --ps ../../$< < /dev/null
mv obj/ps/$*.ps $@
+# Build rules for shell auto-completion.
+
+.PHONY: shell
+shell: bash zsh fish
+
+.PHONY: bash
+bash: bin/sleep-until.bash
+bin/sleep-until.bash: src/completion
+ @mkdir -p bin
+ auto-auto-complete bash --output $@ --source $<
+
+.PHONY: zsh
+zsh: bin/sleep-until.zsh
+bin/sleep-until.zsh: src/completion
+ @mkdir -p bin
+ auto-auto-complete zsh --output $@ --source $<
+
+.PHONY: fish
+fish: bin/sleep-until.fish
+bin/sleep-until.fish: src/completion
+ @mkdir -p bin
+ auto-auto-complete fish --output $@ --source $<
+
# Install rules.
.PHONY: install
-install: install-base install-info install-man
+install: install-base install-info install-man install-shell
.PHONY: install
-install-all: install-base install-doc
+install-all: install-base install-doc install-shell
# Install base rules.
@@ -168,6 +191,26 @@ install-man:
install -dm755 -- "$(DESTDIR)$(MANDIR)/man1"
install -m644 doc/man/sleep-until.1 -- "$(DESTDIR)$(MANDIR)/man1/$(COMMAND).1"
+# Install shell auto-completion.
+
+.PHONY: install-shell
+install-shell: install-bash install-zsh install-fish
+
+.PHONY: install-bash
+install-bash: bin/sleep-until.bash
+ install -dm755 -- "$(DESTDIR)$(DATADIR)/bash-completion/completions"
+ install -m644 $< -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)"
+
+.PHONY: install-zsh
+install-zsh: bin/sleep-until.zsh
+ install -dm755 -- "$(DESTDIR)$(DATADIR)/zsh/site-functions"
+ install -m644 $< -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)"
+
+.PHONY: install-fish
+install-fish: bin/sleep-until.fish
+ install -dm755 -- "$(DESTDIR)$(DATADIR)/fish/completions"
+ install -m644 $< -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish"
+
# Uninstall rules.
@@ -182,6 +225,15 @@ uninstall:
-rm -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME).ps"
-rm -- "$(DESTDIR)$(DOCDIR)/$(PKGNAME).dvi"
-rm -- "$(DESTDIR)$(MANDIR)/man1/$(COMMAND).1"
+ -rm -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish"
+ -rmdir -- "$(DESTDIR)$(DATADIR)/fish/completions"
+ -rmdir -- "$(DESTDIR)$(DATADIR)/fish"
+ -rm -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)"
+ -rmdir -- "$(DESTDIR)$(DATADIR)/zsh/site-functions"
+ -rmdir -- "$(DESTDIR)$(DATADIR)/zsh"
+ -rm -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)"
+ -rmdir -- "$(DESTDIR)$(DATADIR)/bash-completion/completions"
+ -rmdir -- "$(DESTDIR)$(DATADIR)/bash-completion"
# Clean rules.
diff --git a/src/completion b/src/completion
new file mode 100644
index 0000000..7876f18
--- /dev/null
+++ b/src/completion
@@ -0,0 +1,11 @@
+(sleep-until
+ (default (arg CLOCK_OR_TIME) (files -0) (suggest clock)
+ (desc 'Select clock or exit time'))
+
+ (suggestion clock (verbatim CLOCK_REALTIME
+ CLOCK_MONOTONIC
+ CLOCK_BOOTTIME
+ CLOCK_REALTIME_ALARM
+ CLOCK_BOOTTIME_ALARM))
+)
+