How to make alias to systemctl with autocomplete
I tried
alias sct='systemctl'
complete -F _systemctl sct
But the function _systemctl is not found until I run the original command systemctl in the session. This function loads dynamically or somehow and contains many other same functions inside.
OS - Ubuntu 20.04
Create a file named /etc/bash_completion.d/systemctl
:
if [[ -r /usr/share/bash-completion/completions/systemctl ]]; then
. /usr/share/bash-completion/completions/systemctl && complete -F _systemctl systemctl sct
fi
You can restart bash-completion by sourcing . /etc/bash_completion