complete -F _systemctl sct
But I recommend use bash function instead of bash alias so you can define some shortcuts for sub commands, here is an example:
case $1 in
sudo systemctl enable --now "$@"
sudo systemctl disable --now "$@"
systemctl status "$@"
sudo systemctl stop "$@"
sudo systemctl restart "$@"
In addition, in order to make bash completion work for these shortcuts, you need to add them to array
VERBS in corresponding keys in
/usr/share/bash-completion/completions/systemctl. Here is an example for
sct e :
local -A VERBS=(
+ [DISABLED_UNITS]='enable e'
But these modifications in
/usr/share/bash-completion/completions/systemctl may lost over an update. I haven't found a perfect way to override it yet, maybe later.