cobra-shell
cobra-shell copied to clipboard
Fuzzy Suggestions for Autocomplete
Hey!
I implemented a directory walker that outputs e.g. ps1
files recursively in nested folders.
Is it possible to do fuzzy searching on this parameter? I saw fuzzy suggestions are implemented in go-prompt (https://github.com/c-bata/go-prompt/blob/82a912274504477990ecf7c852eebb7c85291772/CHANGELOG.md and https://github.com/c-bata/go-prompt/pull/92).
However, I'm unsure where to set this option and if it is configurable also in cobra-shell. You showed already a nice way to add keybindings. So I thought there may be an easy solution for this as well. :smile:
Sorry it took me a while to respond. We use FilterHasPrefix()
in this repo, but it sounds like you'd like to use FilterFuzzy()
instead? https://github.com/c-bata/go-prompt/blob/82a912274504477990ecf7c852eebb7c85291772/filter.go#L27
I don't think I've seen a shell use fuzzy suggestions by default, so I'd hesitate to support this. Can you tell me a bit more about your use case / why you'd want cobra-shell to support configuring that? (Also, you can always feel free to fork the project to make this change!)
Exactly! A configurable flag for this would be great. The reason for this is the following.
In my args there is a dynamic command list that's generated from a list of files in a directory. In this case it could be e.g. Powershell scripts that I want to choose from. However the files are sorted in subdirectories and when you can only filter by prefix you'll have to type the folder first, even if you know the file name better.
I'll consider a fork but of course I thought sharing my thoughts on this helps understanding the background :)
thanks for the hint towards the line in your code ✌️