photo-stats

statistics processor for the terminal
git clone https://git.clttr.info/photo-stats.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 9102772f09695845876d76bbb14c7b08f999e057
parent 0b507b9c341b31a0e28f6f4b3e5dc8633f804e37
Author: René Wagner <rwa@clttr.info>
Date:   Thu, 20 Apr 2023 19:59:20 +0200

allow completion of multifield-params

Diffstat:
MMakefile | 2+-
Mphosta-completion.sh | 15++++++++++-----
2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile @@ -35,7 +35,7 @@ install: all install -m644 LICENSE $(DESTDIR)/$(DOCDIR)/phosta/LICENSE install -m644 phosta-completion.sh $(DESTDIR)/$(COMPLDIR)/completions/phosta -uninstall: all +uninstall: rm -f $(DESTDIR)/$(BINDIR)/phosta rm -f $(DESTDIR)/$(MANDIR)/man1/phosta.1 rm -f $(DESTDIR)/$(MANDIR)/man5/phosta-alias.5 diff --git a/phosta-completion.sh b/phosta-completion.sh @@ -1,20 +1,24 @@ #!/bin/bash - +# shellcheck disable=SC2207 _phosta_completions() { local cur=${COMP_WORDS[COMP_CWORD]} local prev=${COMP_WORDS[COMP_CWORD-1]} - local suggestions + local prefix="" + if [[ ${cur} =~ "," ]]; then + prefix="${cur%,*}," + fi + local suggestions="" case "${prev}" in "-o") - suggestions=($(compgen -W "year month week hour file maker model lensmaker lens aperture exposuretime iso focallength focallength35mm" "${cur}")) + suggestions=($(compgen -W "${prefix}year ${prefix}month ${prefix}week ${prefix}hour ${prefix}file ${prefix}maker ${prefix}model ${prefix}lensmaker ${prefix}lens ${prefix}aperture ${prefix}exposuretime ${prefix}iso ${prefix}focallength ${prefix}focallength35mm" "${cur}")) ;; "-s") - suggestions=($(compgen -W "file maker model lensmaker lens aperture exposuretime iso focallength focallength35mm" "${cur}")) + suggestions=($(compgen -W "${prefix}file ${prefix}maker ${prefix}model ${prefix}lensmaker ${prefix}lens ${prefix}aperture ${prefix}exposuretime ${prefix}iso ${prefix}focallength ${prefix}focallength35mm" "${cur}")) ;; "-g") - suggestions=($(compgen -W "year month week hour" "${cur}")) + suggestions=($(compgen -W "${prefix}year ${prefix}month ${prefix}week ${prefix}hour" "${cur}")) ;; "-T") suggestions=($(compgen -W "auto on off" "${cur}")) @@ -43,6 +47,7 @@ _phosta_completions() if [ "${#suggestions[@]}" == "1" ]; then # if there's only one match, we remove the command literal # to proceed with the automatic completion of the command + # shellcheck disable=SC2116 suggestion=$(echo "${suggestions[0]/%\ */}") COMPREPLY=("${suggestion}") else