From 6dea60aa9f6b39832792f40b680e46fdaa20a980 Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Tue, 25 Feb 2020 13:56:39 +0100 Subject: [PATCH] Add zsh completion scripts Signed-off-by: Christian Ebner --- Makefile | 7 +++++-- debian/proxmox-backup-client.install | 2 ++ debian/proxmox-backup-server.install | 1 + defines.mk | 1 + zsh-completions/_proxmox-backup-client | 13 +++++++++++++ zsh-completions/_proxmox-backup-manager | 13 +++++++++++++ zsh-completions/_pxar | 13 +++++++++++++ 7 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 zsh-completions/_proxmox-backup-client create mode 100644 zsh-completions/_proxmox-backup-manager create mode 100644 zsh-completions/_pxar diff --git a/Makefile b/Makefile index 7c58a956c..8607a2d69 100644 --- a/Makefile +++ b/Makefile @@ -120,11 +120,14 @@ lint: install: $(COMPILED_BINS) install -dm755 $(DESTDIR)$(BINDIR) + install -dm755 $(DESTDIR)$(ZSH_COMPL_DEST) $(foreach i,$(USR_BIN), \ - install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ;) + install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ; \ + install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;) install -dm755 $(DESTDIR)$(SBINDIR) $(foreach i,$(USR_SBIN), \ - install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ;) + install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ; \ + install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;) install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup $(foreach i,$(SERVICE_BIN), \ install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/ ;) diff --git a/debian/proxmox-backup-client.install b/debian/proxmox-backup-client.install index a6d811660..74b568f17 100644 --- a/debian/proxmox-backup-client.install +++ b/debian/proxmox-backup-client.install @@ -2,3 +2,5 @@ usr/bin/proxmox-backup-client usr/bin/pxar usr/share/man/man1/proxmox-backup-client.1 usr/share/man/man1/pxar.1 +usr/share/zsh/vendor-completions/_proxmox-backup-client +usr/share/zsh/vendor-completions/_pxar diff --git a/debian/proxmox-backup-server.install b/debian/proxmox-backup-server.install index 8df7b5b48..fe3ba602a 100644 --- a/debian/proxmox-backup-server.install +++ b/debian/proxmox-backup-server.install @@ -11,3 +11,4 @@ usr/share/javascript/proxmox-backup/images/proxmox_logo.png usr/share/javascript/proxmox-backup/js/proxmox-backup-gui.js usr/share/man/man1/proxmox-backup-manager.1 usr/share/man/man1/proxmox-backup-proxy.1 +usr/share/zsh/vendor-completions/_proxmox-backup-manager diff --git a/defines.mk b/defines.mk index cd89fa1de..c44ac3bf9 100644 --- a/defines.mk +++ b/defines.mk @@ -8,6 +8,7 @@ MAN1DIR = $(PREFIX)/share/man/man1 DOCDIR = $(PREFIX)/share/doc/proxmox-backup JSDIR = $(DATAROOTDIR)/javascript/proxmox-backup SYSCONFDIR = /etc +ZSH_COMPL_DEST = $(PREFIX)/share/zsh/vendor-completions # For local overrides -include local.mak diff --git a/zsh-completions/_proxmox-backup-client b/zsh-completions/_proxmox-backup-client new file mode 100644 index 000000000..589ff7ddb --- /dev/null +++ b/zsh-completions/_proxmox-backup-client @@ -0,0 +1,13 @@ +#compdef _proxmox-backup-client() proxmox-backup-client + +function _proxmox-backup-client() { + local cwords line point cmd curr prev + cworkds=${#words[@]} + line=$words + point=${#line} + cmd=${words[1]} + curr=${words[cwords]} + prev=${words[cwords-1]} + compadd -- $(COMP_CWORD="$cwords" COMP_LINE="$line" COMP_POINT="$point" \ + proxmox-backup-client bashcomplete "$cmd" "$curr" "$prev") +} diff --git a/zsh-completions/_proxmox-backup-manager b/zsh-completions/_proxmox-backup-manager new file mode 100644 index 000000000..64a74af0f --- /dev/null +++ b/zsh-completions/_proxmox-backup-manager @@ -0,0 +1,13 @@ +#compdef _proxmox-backup-manager() proxmox-backup-manager + +function _proxmox-backup-manager() { + local cwords line point cmd curr prev + cworkds=${#words[@]} + line=$words + point=${#line} + cmd=${words[1]} + curr=${words[cwords]} + prev=${words[cwords-1]} + compadd -- $(COMP_CWORD="$cwords" COMP_LINE="$line" COMP_POINT="$point" \ + proxmox-backup-manager bashcomplete "$cmd" "$curr" "$prev") +} diff --git a/zsh-completions/_pxar b/zsh-completions/_pxar new file mode 100644 index 000000000..1b77a4032 --- /dev/null +++ b/zsh-completions/_pxar @@ -0,0 +1,13 @@ +#compdef _pxar() pxar + +function _pxar() { + local cwords line point cmd curr prev + cworkds=${#words[@]} + line=$words + point=${#line} + cmd=${words[1]} + curr=${words[cwords]} + prev=${words[cwords-1]} + compadd -- $(COMP_CWORD="$cwords" COMP_LINE="$line" COMP_POINT="$point" \ + pxar bashcomplete "$cmd" "$curr" "$prev") +}