oh-my-zsh 没有systemctl的智能不全插件。自己照着docker的插件写了一个。记录一下。
#compdef systemctl # Systemctl autocompletion for oh-my-zsh # Requires: Systemd installed # Author: Hpc # ----- Commands # Seperate function for each command, makes extension easier later # --------------------------- __systemd_services() { declare -a cont_cmd cont_cmd=($(ls -R /usr/lib/systemd/system/ | grep -v '/')) if [[ 'X$cont_cmd' != 'X' ]] _describe 'systemctl' cont_cmd } __restart() { __systemd_services } __start() { __systemd_services } __status() { __systemd_services } __daemon-reload() { __systemd_services } __stop() { __systemd_services } # end commands --------- # ---------------------- local -a _1st_arguments _1st_arguments=( "restart":"Restart a running service"