I would like tab completion to behave differently when the cursor is at the beginning of a word than when the cursor is at the end of a word.
I've only ever seen shells that tab-complete the suffix, like this:
$ tiff2␣
tiff2bw tiff2pdf tiff2ps tiff2rgba
However, sometimes I would also like to tab-complete the prefix
when the caret is at the beginning of the word.
That is, I want to expand to all the commands that end in 2tiff
if the cursor is at the beginning of the word 2tiff
, like this:
$ ␣2tiff
raw2tiff gif2tiff bmp2tiff ppm2tiff pnmtotiff ras2tiff e2mtiff fax2tiff
Fish does this in some cases:
~> ␣2tiff
bmp2tiff (Executable, 17kB) ppm2tiff (Executable, 14kB)
fax2tiff (Executable, 18kB) ras2tiff (Executable, 14kB)
gif2tiff (Executable, 18kB) raw2tiff (Executable, 17kB)
This also has the side effect of moving the cursor to the end of the word, and only works if there is no valid suffix completion:
~> ␣tiff
tiff2bw (Convert a color TIFF image to greyscale)
tiff2pdf (Convert a TIFF image to a PDF document)
tiff2ps (Convert a TIFF image to)
tiff2rgba (Convert a TIFF image to RGBA color space)
…and 10 more rows
I cannot find a way to make bash
or zsh
do prefix tab-completion in either case.