add completions for bash and fish
arĉi arcxi@dismail.de
Tue, 18 Jun 2024 21:35:21 +0200
2 files changed,
23 insertions(+),
0 deletions(-)
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)"