Replies: 5 comments · 6 replies
-
After disabling autosuggestions (I don't like that they pull from history)
FWIW to only make them use the current session, you can use
set fish_private_mode 1
or "set fish_history tmp" to create a separate, named history file.
To demonstrate the problem, I have the following directory structure (directories marked with trailing `/`):
```
~/fish-test/foo/ ~/fish-test/foo.json ~/fish-test/fooo/ ~/fish-test/futhark-book.readthedocs.io/
```
After moving into `fish-test/`, the following behavior occurs:
- After typing `cd foo`, pressing tab pops up the completions `foo/ fooo/`
- After typing `cd fooo`, pressing tab completes to `fooo/`
- After typing `cd foooo`, it shows as red (no matches), but pressing tab completes to `futhark-book.readthedocs.io/`
when you press tab, fish computes completions and groups them by "match quality", from best to worse:
1. exact prefix matches
2. case-insensitive prefix matches
3. exact substring matches
4. case-insensitive substring matches
5. subsequence matches (i.e. your last example)
then fish only shows you all completions of the best group.
We could probably add a configuration option to only
do 1 and 2, which is essentially what Bash and others do
(i.e. "tab never second-guesses user input").
If we want to make it more flexible, we could add a user-overridable
callback function to filter completions.
That function can access the current token (`commandline --current-token`)
and implement the strict prefix matching.
But that would make it harder to complete things like `echo {foo,bar`,
so maybe boolean options are the way to go.
But it'd need some work.
Instead of setting such a global option, I'd personally use ctrl-/ or
ctrl-z to undo individual expansions as needed.
|
Beta Was this translation helpful? Give feedback.
-
We try pretty hard to not add new configuration options, in line with the fish design principles. Is there a way we can make completions more predictable? I understand that the third case above is contrived but I agree it's a bit unexpected. I'm not sure that subsequence matching ever produces results that people expect (I feel like we've discussed this before but haven't had time to go digging) |
Beta Was this translation helpful? Give feedback.
-
I'm not sure that subsequence matching ever produces results that people expect
I use it as a shortcut, so
"ls uniq3\<tab>" expands to
"ls low-entropy-prefix-with-unique-bit--part-3.suffix"
without me having the press tab thrice.
(For files I can use wildcards instead nowadays: "ls *uniq*3\<tab>")
IDE autocompletion and fuzzy matchers are forgiving in the same way
(subsequence semantics) whereas web browsers and traditional programs
like Bash or Emacs (ido etc) do not.
Our approach is certainly predictable (since completions will be
sorted alphabetically rather than via a fuzzy rank heuristic) but of
course it may be surprising to people used to the "never ever insert
false positives" behavior.
|
Beta Was this translation helpful? Give feedback.
-
My use case: the command You can show the overly fuzzy matches like bash does on second TAB press, and maybe even start going between between the fuzzies on repeated TABs like fish already does, but please don't put it on the edit line without further user action. The jarring results of running random commands accidentally are just too weird for me to be able to use fish as-is. |
Beta Was this translation helpful? Give feedback.
-
I wonder if we can find a better default solution, like asking for confirmation when tab does a subsequence replacement on the commandline.
I'm not too hopeful but it's possible to try.
*show* the overly fuzzy matches like bash does on second TAB press
FWIW bash does not have fuzzy (subsequence) matches by default; the second TAB only serves to show ambiguous completions.
To show all cargo commands we need "car TAB TAB TAB", we could change Bash to not require the second TAB.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! I've been trying out Fish today. After disabling autosuggestions (I don't like that they pull from history + I'm switching from Bash so wanted to make things familiar for now) and adding aliases / abbreviations, I've got Fish mostly in a way I like it.
However, I do not like the behavior of tab-completion: specifically that tab-complete will sometimes complete to files and directories that do not match the current prefix verbatium. This is unpredictable to me and I would rather a command fail to match a file than autocomplete to a fuzzy match I did not intend it to. How might I configure tab-complete to only complete things that match the current prefix exactly?
To demonstrate the problem, I have the following directory structure (directories marked with trailing
/
):After moving into
fish-test/
, the following behavior occurs:cd foo
, pressing tab pops up the completionsfoo/ fooo/
cd fooo
, pressing tab completes tofooo/
cd foooo
, it shows as red (no matches), but pressing tab completes tofuthark-book.readthedocs.io/
The first two behaviors are desirable and I'd like to keep them. The last is absolutely undesirable and I'd like for it to never happen when completing file names. How might I make this so?
Beta Was this translation helpful? Give feedback.
All reactions