From bb1ce65aa7535993350929da04a4538e6b40b71a Mon Sep 17 00:00:00 2001 From: Mark Oteiza Date: Mon, 1 Sep 2014 13:46:53 -0400 Subject: [PATCH] Add bash and zsh completions for llppac Use two separate lists (llpp.in, llppac.in) of file extensions and templates ({bash,zsh}/{llpp,llppac}.mk) to generate completions for both executables and both shells. The script mkcomp.sh facilitates this. Added option completion for llpp and llppac in zsh Employ a Makefile for building/installing the files --- misc/completions/Makefile | 27 ++++++++++++++++++++ misc/completions/README | 56 +++++++++++++++++++++++------------------ misc/completions/bash/llpp | 1 - misc/completions/bash/llpp.mk | 1 + misc/completions/bash/llppac.mk | 1 + misc/completions/llpp.in | 9 +++++++ misc/completions/llppac.in | 52 ++++++++++++++++++++++++++++++++++++++ misc/completions/mkcomp.sh | 47 ++++++++++++++++++++++++++++++++++ misc/completions/zsh/_llpp | 3 --- misc/completions/zsh/llpp.mk | 20 +++++++++++++++ misc/completions/zsh/llppac.mk | 7 ++++++ 11 files changed, 195 insertions(+), 29 deletions(-) create mode 100644 misc/completions/Makefile rewrite misc/completions/README (83%) delete mode 100644 misc/completions/bash/llpp create mode 100644 misc/completions/bash/llpp.mk create mode 100644 misc/completions/bash/llppac.mk create mode 100644 misc/completions/llpp.in create mode 100644 misc/completions/llppac.in create mode 100644 misc/completions/mkcomp.sh delete mode 100644 misc/completions/zsh/_llpp create mode 100644 misc/completions/zsh/llpp.mk create mode 100644 misc/completions/zsh/llppac.mk diff --git a/misc/completions/Makefile b/misc/completions/Makefile new file mode 100644 index 0000000..57950cc --- /dev/null +++ b/misc/completions/Makefile @@ -0,0 +1,27 @@ +# Create shell completions + +COMPLETIONS = bash/llpp bash/llppac zsh/llpp zsh/llppac + +# paths +PREFIX ?= /usr/local +datadir ?= ${PREFIX}/share + +all: ${COMPLETIONS} + +clean: + ${RM} ${COMPLETIONS} + +install: all + install -d ${DESTDIR}${datadir}/bash-completion/completions + install -m644 bash/{llpp,llppac} \ + ${DESTDIR}${datadir}/bash-completion/completions + install -d ${DESTDIR}${datadir}/zsh/site-functions + install -m644 zsh/llpp ${DESTDIR}${datadir}/zsh/site-functions/_llpp + install -m644 zsh/llppac ${DESTDIR}${datadir}/zsh/site-functions/_llppac + +%: mkcomp.sh llpp.in %.mk + @sh mkcomp.sh $* + +bash/llppac zsh/llppac: llppac.in + +.PHONY: all clean install diff --git a/misc/completions/README b/misc/completions/README dissimilarity index 83% index 29115df..8648bcc 100644 --- a/misc/completions/README +++ b/misc/completions/README @@ -1,25 +1,31 @@ -Shell completion -================ - -This directory contains files for enabling tab completion in user shells. -Instruction for some shells follows: - -Bash ----- - -If you have `bash-completion` installed, you can install `llpp` in the `bash/` -directory into wherever that package's completions are stored, typically in -`/usr/share/bash-completion/completions/`. Alternatively, you can just copy -the contents into or source it in your `~/.bashrc`. - -Zsh ---- - -To enable completion for `llpp`, install `_llpp` to a directory in zsh's -`$fpath`. Packages generally put their zsh completions in the directory -`/usr/share/zsh/site-functions/`. Alternatively, for the same effect, one can -add something like: - - compdef "_files -g '*.(pdf|xps|zip|cbz|jpg|png)'" llpp - -to `.zshrc`. +Shell completion +================ + +This directory contains files for enabling tab completion in user shells. + + Makefile + mkcomp.sh Script which generates completion files from the following: + llpp.in Config file with file extensions for llpp + llppac.in Config file with file extensions for llppac + */*.mk Shell completion templates + +Building +-------- + +Run `make` to generate bash and zsh completions for llpp and llppac from +`llpp.in`, `llppac.in`, and the templates in `bash/` and `zsh/`. + +Installation +------------ + +Bash +~~~~ + +Install the completions into wherever the `bash-completion` package's +completions are stored, typically in `/usr/share/bash-completion/completions/`. + +Zsh +~~~ + +Install the completions to a directory in zsh's `$fpath`. Packages generally +put their zsh completions in the directory `/usr/share/zsh/site-functions/`. diff --git a/misc/completions/bash/llpp b/misc/completions/bash/llpp deleted file mode 100644 index 68a4e0b..0000000 --- a/misc/completions/bash/llpp +++ /dev/null @@ -1 +0,0 @@ -complete -f -X '!*.@(pdf|xps|zip|cbz|jpg|jpeg|png)' -o plusdirs llpp diff --git a/misc/completions/bash/llpp.mk b/misc/completions/bash/llpp.mk new file mode 100644 index 0000000..b6b6575 --- /dev/null +++ b/misc/completions/bash/llpp.mk @@ -0,0 +1 @@ +complete -f -X '!*.@@re@' -o plusdirs llpp diff --git a/misc/completions/bash/llppac.mk b/misc/completions/bash/llppac.mk new file mode 100644 index 0000000..7c2e3ac --- /dev/null +++ b/misc/completions/bash/llppac.mk @@ -0,0 +1 @@ +complete -f -X '!*.@@re@' -o plusdirs llppac diff --git a/misc/completions/llpp.in b/misc/completions/llpp.in new file mode 100644 index 0000000..73cf1f8 --- /dev/null +++ b/misc/completions/llpp.in @@ -0,0 +1,9 @@ +# list of file extensions for llpp + +pdf +xps +zip +cbz +jpg +jpeg +png diff --git a/misc/completions/llppac.in b/misc/completions/llppac.in new file mode 100644 index 0000000..19aae4f --- /dev/null +++ b/misc/completions/llppac.in @@ -0,0 +1,52 @@ +# list of extensions for llppac + +# archives +gz +Z +xz +bz2 + +# postscript, djvu, and other documents +ps +eps +djv +djvu +dvi +doc +docx +ppt +pptx +xls +odf +odg +odp +ods +odt + +# images +bmp +gif +pbm +ppm +pgm +svg +svgz +tif +tiff +xbm +xpm +xcf + +# images (raw formats) +arw +cr2 +crw +nef +nrw +raf +raw +x3f + +# fonts +otf +ttf diff --git a/misc/completions/mkcomp.sh b/misc/completions/mkcomp.sh new file mode 100644 index 0000000..5345269 --- /dev/null +++ b/misc/completions/mkcomp.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# mkcomp --- make completion files +# +# Usage: mkcomp