programmable completion on expanded aliases not working (shopt -s progcomp_alias)
In Bash 5, there is a progcomp_alias shopt parameter. From man shopt:
If set, and programmable completion is enabled, bash treats a command name that doesn't have any completions as a possible alias and attempts alias expansion. If it has an alias, bash attempts programmable completion using the command word resulting from the expanded alias.
Let's take an example with systemctl
If I type systemctl <TAB><TAB> I get programmable completion:
add-requires enable is-system-running preset show
add-wants exit kexec preset-all show-environment
cancel force-reload kill reboot start
cat get-default link reenable status
condreload halt list-dependencies reload stop
condrestart help list-jobs reload-or-restart suspend
condstop hibernate list-machines rescue suspend-then-hibernate
daemon-reexec hybrid-sleep list-sockets reset-failed switch-root
daemon-reload import-environment list-timers restart try-reload-or-restart
default is-active list-unit-files revert try-restart
disable is-enabled list-units set-default unmask
edit is-failed mask set-environment unset-environment
emergency isolate poweroff set-property
Now if I create an alias with alias s=systemctl and turn on progcomp_alias with shopt -s progcomp_alias I would expect that when I type s <TAB><TAB> to see the programmable completion above. Yet it doesn't work and propose only regular file completion. Am I using the progcomp_alias option wrong or not understanding what it does ?
Posted Jan 19, 2020, 1:57 PM UTC · edited
Pretty sure
shas pleanty of completions.I suppose the doc means if the command is an existing complete command (which
sis not). You canalias cvsjkdnfkjsdf=systemctland it will not work either andcvsjkdnfkjsdfhas no completion...