Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

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 /):

~/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/

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?

You must be logged in to vote

Replies: 5 comments · 6 replies

Comment options

You must be logged in to vote
4 replies
@krobelus
Comment options

see completion_rank() for where this logic is implemented

@omentic
Comment options

Thanks for the detailed response! I can't seem to find that completion_rank() function, though. Where is it located?

@krobelus
Comment options

sorry that was an unpublished patch -- look for get_best_rank

@omentic
Comment options

Okay, I'll check that out and see about making a patch. (Will get back to that other patch soon too.)

Comment options

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)

You must be logged in to vote
1 reply
@omentic
Comment options

I understand the opposition to configuration options -- I've seen the fish design principles implicit in other issues around here. I'm going to try to make a good case for it, regardless, after writing the patch.

What I'll probably argue along the lines of is 1) tab completion behavior is a very fundamental way of interacting with the shell so it makes sense to have more options there, 2) the current behavior of non-verbatium completions is useful for completions but unpredictable which makes errors in typing potentially very bad (eg. around rm), 3) with such a patch and the recent #11250, fish can be brought into nearly 1:1 behavior with bash (though I know this is less convincing for fish folks).

The subsequence matching seems very unpredictable and I'd agree I don't see a good reason for having it. I would say though: it's not about making completions more predictable exactly, it's about making completions accurate -- if I've mistyped something I'm generally making a mistake and I don't want fish to fuzzy-guess what I meant, because by virtue of me having made a mistake fish will never be able to guess perfectly.

(Ex. did i forget to capitalize a letter? did i press "f" when i meant to press "g"? this isn't something fish can know)

Comment options

You must be logged in to vote
0 replies
Comment options

My use case: the command car expanding to blkdiscard just because I don't have cargo in $PATH at the moment. Give me a failure to complete not random things, please.

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.

You must be logged in to vote
1 reply
@omentic
Comment options

I'm working on a patch, FYI, but have been waylaid by actual responsibilities... it'll be primarily for me locally but I'm going to see about getting it into a form the Fish maintainers might be interested in. And if they're not, it'll be available for others to pull down.

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.