command line substring completion

Xfce file dialogs let you type in substrings to filter files.
E.g. if you have anaconda-webui.log and anaconda.log, type ui.

Can you do that with a shell?

cat ui and hit a magic key?
 
most shells have the concept of "file completion". In tcsh/csh you add "set filec" to the init file then the TAB key is used to do the completion.
 
On zsh (and if I recall correctly, {t}csh and some others excluding /bin/sh), incremental completions would work.

For example, if the 2 files you mentioned is in current working directory and there are no other files starting from "an", type "an" then hit Tab key would complete it to "anaconda". Then, if you additionally type "-" and hit Tab key, completed to anaconda-webui.log.
If you type "." instead of "-", completed to anaconda.log.

Is it sufficient for you?
 
Last edited:
Do you see a chance of substring completion getting implemented in /bin/sh ?
I would have to open an enhancement request?
 
On ZFS (and if I recall correctly, {t}csh and some others excluding /bin/sh), incremental completions would work.
Filename completion is a feature of the shell, not the filesystem. If the shell supports it, it won't matter what filesystem, UFS. ZFS, ext2/3/4, FAT, etc.

That said, tcsh(1) comes with a bunch of example custom completions, including ZFS specific ones, you can find those in /usr/share/examples/tcsh/complete.tcsh. As far as I know sh(1) doesn't allow customization of the completions.
 
Do you see a chance of substring completion getting implemented in /bin/sh ?
I would have to open an enhancement request?
Define "substring completion". If you mean "filename completion" then I believe /bin/sh already does that. At least on my system with stock init files filename completion works with at least the ls command.
 
he wants fname completion with any substring like "rofi" shows .profile and such
you may hack libedit src/contrib/libedit.
 
Back
Top