Automatically rebuild custom assets when necessary · Issue #2085 · sharkdp/bat (original) (raw)

I would like to suggest updating the completion scripts to prevent autocompleting the cache subcommand alongside file names. This will eventually be done when this issue is closed, but I believe there is good reason to do it immediately:

Imagine this situation (which gets me almost every day):

  1. I make a new folder and cd into it
  2. I use cp or mv to copy/move in a file, let's call it foo.bar
  3. I want to view foo.bar with bat
  4. Knowing there is only one file in this directory, I type bat , hit tab and enter, expecting the foo.bar to get completed
  5. Nothing got completed because Bash doesn't know whether to complete cache or foo.bar
  6. bat got run, so bat hangs while waiting for input on stdin

You can argue that this is user error on my part, or that my fingers are too fast for my own good (which could be true), but I would insist that the completion script is at fault here. The reason is simply that this behaviour is dissimilar to most other commonly-used tools (e.g. cat, diff, your favourite editor, etc.), and is certainly not what the user expects.

And in return for the constant frustration, the benefit is clearly minimal. The bat-cache subcommand is very rarely used if ever (at least in my experience), so its existence in the completion script is more of a stumbling block than anything else.

Therefore I think it's a good idea to remove it right now from all completion scripts. Should be only a few lines of deletion. If people agree with this opinion then I'm happy to go ahead and create a PR.

P.s. I'm only suggesting the removal of the autocompletion of the word cache, not the removal of the autocompletion of bat-cache's flags. These don't really cause trouble and can stay until the subcommand gets removed entirely.