sshs icon indicating copy to clipboard operation
sshs copied to clipboard

Fuzzy finding

Open J-PC opened this issue 7 months ago • 1 comments

I have long names for the machines with or without character dividers '-', '/'

I'd like to be able to fuzzy find the machines names. The search is too strict when searching something.

Two approaches could work.

The first one could be to implement a search feature like in tssh (https://github.com/trzsz/trzsz-ssh) :

For example, with a name of machine like "exemple_machine_name_xxxxx" or "production/exemple_machine_name_xxxxx" : all the following searches should work :

exemple xxxxx exem xxx exem me_xxx prod exem xxx on/ex ame_xxx xx exemple prod xxx exem

All the searches work because it searches contiguous strings and apply an "and" between the strings. The order of the strings doesn't matter. It's just "and" logic. This is how it works with tssh.

The second option is doing true fuzzy finding like fzf (https://github.com/junegunn/fzf) :

All the above still applies but we can release one constraint being contiguity. There is no sense of wording but just of ordering between characters. The following searches would work in true fuzzy finding :

exemplema xxxxx exema chinxxx inexxx exemplema exema chinxxx prodexena

The second option is the most complete

I guess it could even complement the feature request (https://github.com/quantumsheep/sshs/issues/22) which somehow creates a tree structure with host groups where fuzzy finding could allow to find through the tree very quickly like fzf does with filesystems/paths.

J-PC avatar Jun 27 '25 11:06 J-PC

Hi J-PC,

I implemented sorting by Levenshtein distance (https://github.com/quantumsheep/sshs/pull/140). This covers most of your examples in the first group. It fails on the last two, and you have to skip the spaces, e.g., prodexemxxx.

OmenWild avatar Jul 11 '25 00:07 OmenWild