💾 Archived View for gmn.clttr.info › sources › photo-stats.git › tree › phosta-completion.sh.txt captured on 2023-11-04 at 11:58:04.
⬅️ Previous capture (2023-09-08)
-=-=-=-=-=-=-
#!/bin/bash # shellcheck disable=SC2207 _phosta_completions() { local cur=${COMP_WORDS[COMP_CWORD]} local prev=${COMP_WORDS[COMP_CWORD-1]} local suggestions="" local suggestions=($(compgen -W "-o -s -g -T -n -W -t -p -D -c -E -e -f -n")) local prefix="" if [[ ${cur} =~ "," ]]; then prefix="${cur%,*}," fi case "${prev}" in "-o") 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 "\"${prefix}file \"${prefix}maker \"${prefix}model \"${prefix}lensmaker \"${prefix}lens \"${prefix}aperture \"${prefix}exposuretime \"${prefix}iso \"${prefix}focallength \"${prefix}focallength35mm" "${cur}")) ;; "-f") 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 "${prefix}year ${prefix}month ${prefix}week ${prefix}dayofmonth ${prefix}dayofweek ${prefix}hour" "${cur}")) ;; "-T") suggestions=($(compgen -W "auto on off" "${cur}")) ;; "-n") suggestions=($(compgen -W "1 3 5 10 20 50 100" "${cur}")) ;; "-W") suggestions=($(compgen -W "80 100 120" "${cur}")) ;; "-t") if [ "${cur}" == "" ]; then suggestions=($(compgen -W "$(date +%Y)0101-$(date +%Y)1231")) else suggestions=($(compgen -W "${cur}0101-${cur}1231" "${cur}")) fi ;; "-p") suggestions=($(compgen -d "${cur}")) ;; "-D") suggestions=($(compgen -f "${cur}")) ;; esac 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 # more than one suggestions resolved, # respond with the suggestions intact COMPREPLY=("${suggestions[@]}") fi return 0 } complete -o nospace -F _phosta_completions phosta