fish-shell icon indicating copy to clipboard operation
fish-shell copied to clipboard

Don't autocomplete already supplied arguments

Open nagisa opened this issue 12 years ago • 4 comments

There's two files in current working directory:

  • [f] a.png
  • [f] b.png

When writting command

rm [f\]\ a.png [f\]\ b.png

I can resort to autocompletions to write command faster.

So instead of writing whole name I can press [ and then , however when writing second filename it again suggests [f]\ a.png, which is already to be removed. I have to resort to Tab then writing b and pressing Tab again which could be avoided if fish didn't autocomplete filenames that were already supplied.

EDIT: Same with flags

nagisa avatar Jul 16 '12 12:07 nagisa

Seems reasonable,

ridiculousfish avatar Jul 16 '12 20:07 ridiculousfish

How would fish distinguish this from commands where passing the same argument multiple times actually has meaning? For example, passing the same file to different switches.

lilyball avatar Jul 17 '12 02:07 lilyball

A very good point indeed.

Switchless arguments

In roughly 90% of cases (no statistical proof, just a guess based on observations) it is intended to pass different arguments. Minority of use cases that require same argument several times would resort to using Tab+...+Tab completions.

Switches... It is much more complicated.

Man pages always (again, just observation, no proof) contains --switch=PSEUDO_VAR and/or --switch[=PSEUDO_VAR]. Currently generated completions doesn't keep track of the fact, that switch requires a value (or that it is optional). Fish could keep track of that and then autocomplete it using rules as shown below.

# Assuming that there's two files in current working directory. '[f] a.png' and '[f] b.png'
clang -o [_f\]\ a.png_
clang -o [_f\]\ a.png_ -o [_f\]\ b.png_

I couldn't find any command that would take multiple files for one switch, so I used clang with multiple outputs (it doesn't). Auto-completed part is denoted by _.

That's just a quick and dirty idea how to go around handling values for switches and I'm not sure if it would work.

So fish's --switch=value auto-complete behaviour could be same as it is now until someone proposes a really good solution.

nagisa avatar Jul 17 '12 11:07 nagisa

@nagisa wrote:

I couldn't find any command that would take multiple files for one switch, so I used clang with multiple outputs (it doesn't). Auto-completed part is denoted by _.

clang -I <directory1> -I <directory2> ... While it's not a file match, it's essential the same issue 😉

Shea690901 avatar Nov 26 '23 19:11 Shea690901