[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: why bash completion sometimes doesn't work?



On Mon, Jan 03, 2022 at 05:25:31AM +0000, Long Wind wrote:
> when i type "ifdown wl" and press Tab, it shall complete it with full device name wlx12345
> i believe it's taken from /etc/network/interfaces
> but sometimes it doesn't work in buster

You're describing "programmable completion", which is an optional
feature of bash.  It's done on a per-command basis.  E.g. if you
type "cd wlx<TAB>" it will not complete the wlx word using interface
names, because there is no such completion defined for the "cd" command.
Apparently there is (on your system) for "ifdown" though.

By default, Debian installs the bash-completion package, which contains
programmable completions for a whole bunch of commands.  This is
enabled by dotting in a file from ~/.bashrc (the code to do this is
at the end of /etc/skel/.bashrc, which becomes the default user ~/.bashrc
file if you add users with "adduser").

Unless told otherwise, we're going to assume you're using bash (not zsh)
as your shell, and that you've got the standard Debian ~/.bashrc file,
so that bash's programmable completion has been enabled.

If some programmable completion isn't working the way you expect, then
you need to gather some more information.  Give us the versions of
the bash and bash-completion packages that you've got installed, and
then tell us the EXACT command you typed, and what results you got by
pressing Tab.


Reply to: