xmonad / xmonad-contrib

Contributed modules for xmonad
https://xmonad.org
BSD 3-Clause "New" or "Revised" License
588 stars 274 forks source link

XMonad.Prompt.Pass: Missing generic search feature #746

Closed Maeda1 closed 2 years ago

Maeda1 commented 2 years ago

Problem Description

This is more a feature request than a problem.

Current problem: when opening the prompt in XMonad.Prompt.Pass, one must type the very first characters of an existing first level folder in $HOME/.password-store to show/match entries.

Pass utility has the find argument that can search based on a keyword and match any folder or any GPG file that contains the keyword, which is much more easier to find a password entry.

Steps to Reproduce

Assuming you have this $HOME/.password-store example entries: $HOME/.password-store/www/github/email.gpg $HOME/.password-store/www/github/password.gpg $HOME/.password-store/other/mybestwebsite/password.gpg

Using XMonad.Prompt.Pass:

Using pass:

That is a much better behavior and expected to have the same when using XMonad.Prompt.Pass

Checklist

slotThe commented 2 years ago

What you're probably looking for is X.P.FuzzyMatch, which implements a fuzzy search for the prompt

geekosaur commented 2 years ago

Only if you can integrate it with pass(1) somehow. I suspect that's what the find subcommand to it does.

Maeda1 commented 2 years ago

fuzzyMatch is indeed very close to what pass find does, except that it matches others too:

Example: "spr" matches FastSPR but also SuccinctParallelTrees because it's a subsequence of the latter: "S.......P.r..........".

Because of fuzzySort good relevance sorting (e.g., making "spr" matches first), I am adopting fuzzyMatch as a good solution.

Besides, that should be included by default for Prompt.pass, or highly recommended in the Prompt.pass documentation.

slotThe commented 2 years ago

Besides, that should be included by default for Prompt.pass, or highly recommended in the Prompt.pass documentation.

You're probably right; I can't imagine people wanting to type out the whole path to their password every time. We should probably document this default though, in case users do want that. Fancy opening a PR?

Maeda1 commented 2 years ago

You mean pull request by changing $usage in Pass.hs to add a note about that?

slotThe commented 2 years ago

I mean changing mkPassPrompt to automatically apply the fuzzy matcher and sorter, as well as document this in the module so that users who do not wish to use these features (or use other search predicates and sorters) know to turn them off.

(This would of course break backwards compatibility, but I think it's a worthwhile trade off to having yet another mkPassPrompt')

Maeda1 commented 2 years ago

I am afraid that is out of my skills :disappointed:

slotThe commented 2 years ago

No worries, I'll (try to, time permitting) prepare something tomorrow then