easier selection of passwords

Arden Zhan arden at pm.me
Fri Mar 19 05:40:09 UTC 2021


> On Sat, 2021-02-20 at 14:18 -0500, Alec Hill wrote:
> > On Wed, Feb 17, 2021 at 11:39 AM Matt Connell <matt at connell.tech> wrote:
> > > On Wed, 2021-02-17 at 11:28 -0500, Alec Hill wrote:
> > > > Optimally, the shell completion would allow me to omit the directories
> > > > and just the password file name to be able to then `tab` through the
> > > > results and select the desired one.
> > >
> > > My pass tab completion does this... and as I recall I didn't do
> > > anything in particular to make that happen, it just always worked that
> > > way.
> >
> > Oh that's interesting.  Are you using bash shell?  I'm using zsh, and
> > my completion requires me to enter the directories.
>
> I am using bash.  I do have a package installed called app-shells/bash-
> completion (Gentoo) that may be providing this functionality.  Not
> sure.  Never used a machine that I didn't install it on :)  But other
> distros should offer something similar.

I also can't get tab completion in bash without specifying the sub directory
with neither app-shells/bash-completion nor pass's built in bash completion.

For me the best alternative is to use fzf and a custom fuzzy completion [1].
This example uses code from pass's zsh completion helper [2].

_fzf_complete_pass() {
  _fzf_complete +m -- "$@" < <(
    local prefix
    prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
    command find -L "$prefix" \
      -name "*.gpg" -type f | \
      sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' -e 's#\\#\\\\#' | sort
  )
}

`pass **<TAB>` to trigger the completion, search and Ctrl+J/K to select the entry.
Setting up a dedicated completion key [3] makes the flow a little faster.

Just saw that this same discussion happened a few years ago too [4].

[1] https://github.com/junegunn/fzf/wiki/Examples-(completion)
[2] https://git.zx2c4.com/password-store/tree/src/completion/pass.zsh-completion#n127
[3] https://github.com/junegunn/fzf/wiki/Configuring-fuzzy-completion
[4] https://lists.zx2c4.com/pipermail/password-store/2015-September/001745.html


More information about the Password-Store mailing list