Hi, this issue is bothering me as well. Also, there are bug reports in several pass extension projects, see
* https://github.com/tadfisher/pass-otp/issues/137 * https://github.com/roddhjav/pass-update/issues/25 to name just two. I figure they have no chance of fixing it in their code base. Regards Timm On Thu, Dec 01, 2022 at 07:19:38PM +0000, Simon Blum wrote: > Hello, > > I'm new here, so let me know if there already is an ongoing discussion on > this topic or if I get anything wrong about this. > > I noticed that some extensions for pass (like pass-update or pass-tomb) > provide completion files, which are poorly integrated in pass. This is due > to the fact, that completion files are loaded dynamically on demand. For > example in bash the file $BASHCOMPDIR/pass is loaded when you enter "pass > <TAB>". As the completion file for pass-update is stored in > $BASHCOMPDIR/pass-update it is not loaded unless you type "pass-update > <TAB>". The completion files in fish and zsh are handled in a similar > manner. > > I'd like to suggest a fix for that issue. The completion files of pass may > automatically seek completion files of extensions and source them. Enclosed > you find a patch that provides that feature together with example completion > files for the extension pass-file. > > Regards, > Simon Blum > > # completion file for bash > > PASSWORD_STORE_EXTENSION_COMMANDS+=("file") > > __password_store_extension_complete_file() { > local cur="${COMP_WORDS[COMP_CWORD]}" > case "$COMP_CWORD" in > 2) > COMPREPLY+=($(compgen -W "add get" -- ${cur})) > ;; > 3) > case "${COMP_WORDS[2]}" in > a|add) > COMPREPLY+=($(compgen -f ${cur})) > ;; > g|get) > _pass_complete_entries 1 > ;; > esac > ;; > 4) > case "${COMP_WORDS[2]}" in > a|add) > _pass_complete_entries > ;; > esac > ;; > esac > } > #autoload > > PASSWORD_STORE_EXTENSION_COMMANDS+=("file:add/get file to/from > password-store") > > __password_store_extension_complete_file () { > case "$CURRENT" in > 2) > local -a subcommands > subcommands=( > "add:add file to password-store" > "get:get file from password-store" > ) > _describe -t commands 'pass' subcommands > ;; > 3) > local cmd=${words[2]} > case "${cmd}" in > a|add) > _files > ;; > g|get) > _pass_complete_entries > ;; > esac > ;; > 4) > local cmd=${words[2]} > case "${cmd}" in > a|add) > _pass_complete_entries > ;; > esac > ;; > esac > } > > unfunction $(basename $(print -P %x)) > set -l PROG 'pass' > > function __fish_pass-file_needs_command > set -l cmd (commandline -opc) > if [ (count $cmd) -eq 2 -a "$cmd[2]" = file ] > return 0 > end > return 1 > end > > function __fish_pass-file_arg_nr_of_command > set -l cmd (commandline -opc) > set -l expected_length (math 2 + $argv[1]) > if [ (count $cmd) -eq $expected_length -a "$cmd[2]" = "file" -a "$cmd[3]" = > $argv[2] ] > return 0 > end > return 1 > end > > complete -c $PROG -f -n '__fish_pass_needs_command' -a file -d 'Command: > add/get file to/from password-store' > > complete -c $PROG -f -n '__fish_pass-file_needs_command' -a add -d 'add file > to password-store' > complete -c $PROG -n '__fish_pass-file_arg_nr_of_command 1 a' > complete -c $PROG -n '__fish_pass-file_arg_nr_of_command 1 add' > complete -c $PROG -f -n '__fish_pass-file_arg_nr_of_command 2 a' -a > "(__fish_pass_print_entries)" > complete -c $PROG -f -n '__fish_pass-file_arg_nr_of_command 2 add' -a > "(__fish_pass_print_entries)" > > complete -c $PROG -f -n '__fish_pass-file_needs_command' -a get -d 'get file > from password-store' > complete -c $PROG -f -n '__fish_pass-file_arg_nr_of_command 1 g' -a > "(__fish_pass_print_entries)" > complete -c $PROG -f -n '__fish_pass-file_arg_nr_of_command 1 get' -a > "(__fish_pass_print_entries)" > -- Herr/Mr Timm Fitschen (er/he) Development T: +49 551 288 76 48-3 E: [email protected] I: indiscale.com IndiScale - Wir machen individuelles Datenmanagement skalierbar. IndiScale GmbH Lotzestraße 22a 37083 Göttingen Amtsgericht Göttingen • HRB 205721 Geschäftsführung Henrik tom Wörden
signature.asc
Description: PGP signature
