diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-11-27 05:43:02 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-11-27 05:43:02 +0100 |
commit | ddf403990084e2bc2c3e9502b4051d162432ca90 (patch) | |
tree | 80e84cf3ea422e79b6eeff0f7f868d95eae92814 | |
parent | add makefile (diff) | |
download | xpybar-ddf403990084e2bc2c3e9502b4051d162432ca90.tar.gz xpybar-ddf403990084e2bc2c3e9502b4051d162432ca90.tar.bz2 xpybar-ddf403990084e2bc2c3e9502b4051d162432ca90.tar.xz |
add shell tab-completion
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | DEPENDENCIES | 1 | ||||
-rw-r--r-- | Makefile | 55 | ||||
-rw-r--r-- | src/xpybar.auto-completion | 17 |
3 files changed, 70 insertions, 3 deletions
diff --git a/DEPENDENCIES b/DEPENDENCIES index 73474a8..d7ec318 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -30,4 +30,5 @@ BUILD DEPENDENCIES: make coreutils sed + auto-auto-complete (optional) @@ -50,8 +50,14 @@ EXAMPLES = mixed moderate test xmonad launchers +.PHONY: default +default: base shell + .PHONY: all -all: bin/xpybar bin/restricted-hdparm +all: base shell + +.PHONY: base +base: bin/xpybar bin/restricted-hdparm bin/xpybar: obj/xpybar.zip mkdir -p bin @@ -73,12 +79,34 @@ bin/restricted-hdparm: obj/restricted-hdparm.o obj/%.o: src/%.c $(CC) -std=c89 -Ofast $(WARN) -c -o $@ $< +.PHONY: shell +shell: bash fish zsh + +.PHONY: bash +bash: bin/xpybar.bash-completion + +.PHONY: fish +fish: bin/xpybar.fish-completion + +.PHONY: zsh +zsh: bin/xpybar.zsh-completion + +obj/xpybar.auto-completion: src/xpybar.auto-completion + @mkdir -p obj + cp $< $@ + sed -i 's/^(xpybar/($(COMMAND)/' $@ + +bin/xpybar.%sh-completion: obj/xpybar.auto-completion + @mkdir -p bin + auto-auto-complete $*sh --output $@ --source $< + + .PHONY: install -install: install-base install-doc +install: install-base install-doc install-shell .PHONY: install-all -install-all: install-base install-man +install-all: install-base install-man install-shell .PHONY: install-base install-base: install-command install-license install-all-examples install-plugins @@ -125,6 +153,24 @@ install-man: doc/man/xpybar.1 install -dm755 -- "$(DESTDIR)$(MAN1DIR)" install -m644 $< -- "$(DESTDIR)$(MAN1DIR)/$(COMMAND).1" +.PHONY: install-shell +install-shell: install-bash install-fish install-zsh + +.PHONY: install-bash +install-bash: bin/xpybar.bash-completion + install -dm755 -- "$(DESTDIR)$(DATADIR)/bash-completion/completions" + install -m644 $< -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)" + +.PHONY: install-fish +install-fish: bin/xpybar.fish-completion + install -dm755 -- "$(DESTDIR)$(DATADIR)/fish/completions" + install -m644 $< -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish" + +.PHONY: install-zsh +install-zsh: bin/xpybar.zsh-completion + install -dm755 -- "$(DESTDIR)$(DATADIR)/zsh/site-functions" + install -m644 $< -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)" + .PHONY: uninstall @@ -146,6 +192,9 @@ uninstall: -rmdir -- "$(DESTDIR)$(DATADIR)/$(PKGNAME)/plugins" -rmdir -- "$(DESTDIR)$(DATADIR)/$(PKGNAME)" -rm -- "$(DESTDIR)$(MAN1DIR)/$(COMMAND).1" + -rm -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)" + -rm -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish" + -rm -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)" diff --git a/src/xpybar.auto-completion b/src/xpybar.auto-completion new file mode 100644 index 0000000..677674d --- /dev/null +++ b/src/xpybar.auto-completion @@ -0,0 +1,17 @@ +(xpybar + (argumented (options -c --configurations) (complete --configurations) (files -f) (arg FILE) + (desc 'Select configuration script')) + + (unargumented (options -h -? --help) (complete --help) + (desc 'Print this help information')) + + (unargumented (options -v --version) (complete --version) + (desc 'Print program name and version')) + + (unargumented (options -C --copying --copyright) (complete --copying) + (desc 'Print copyright information')) + + (unargumented (options -W --warranty) (complete --warranty) + (desc 'Print non-warranty information')) +) + |