small pixel drawing of a pufferfish pa

add completions for bash and fish
arĉi arcxi@dismail.de
Tue, 18 Jun 2024 21:35:21 +0200
commit

925265d8c06f762223ba1748e4dae2e0f47b4207

parent

325f63b1d10252bd0f62bf4cfa61b06cf17ea6ac

2 files changed, 23 insertions(+), 0 deletions(-)

jump to
A contrib/pa-completion.bash

@@ -0,0 +1,16 @@

+_pa() { + if [[ $COMP_CWORD -ne 2 ]]; then return; fi + case "${COMP_WORDS[1]}" in [des]*) + names=() + + # Escape all password names so compgen doesn't break. + while read -r name; do + names+=("$(printf "%q\n" "$name")") + done < <(pa list) + + mapfile -t COMPREPLY < <(compgen -W "${names[*]}" -- "${COMP_WORDS[2]}") + ;; + esac +} + +complete -o filenames -o nospace -F _pa pa
A contrib/pa-completion.fish

@@ -0,0 +1,7 @@

+function __fish_complete_pa_name -d 'Complete pa password names' + set -l cmd (commandline -opc) + test (count $cmd) -eq 2; and string match -q -r '^[des]' $cmd[2] +end + +complete -c pa -f +complete -c pa -n "__fish_complete_pa_name" -a "(pa list)"