Function: pcomplete/systemctl
pcomplete/systemctl is an autoloaded and byte-compiled function
defined in pcmpl-linux.el.gz.
Signature
(pcomplete/systemctl)
Documentation
Completion for the systemctl command.
Source Code
;; Defined in /usr/src/emacs/lisp/pcmpl-linux.el.gz
;;;###autoload
(defun pcomplete/systemctl ()
"Completion for the `systemctl' command."
(let ((subcmds (pcomplete-from-help
"systemctl --help"
:margin (rx bol " " (group) alpha)
:argument (rx (+ (any alpha ?-)))
:metavar (rx (group (+ " " (>= 2 (any upper "[]|."))))))))
(while (not (member (pcomplete-arg 1) subcmds))
(if (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-long-option-completion-table
(pcomplete-from-help "systemctl --help"
:metavar "[^ ]+"
:separator " \\(\\)-")))
(pcomplete-here subcmds)))
(let ((subcmd (pcomplete-arg 1))
(context (if (member "--user" pcomplete-args) "--user" "--system")))
(while (pcase subcmd
((guard (string-prefix-p "-" (pcomplete-arg 0)))
(pcomplete-here
(pcomplete-from-help "systemctl --help")))
;; TODO: suggest only relevant units to each subcommand
("start"
(pcomplete-here
(pcmpl-linux--systemd-units context "--state" "inactive,failed")))
((or "restart" "stop")
(pcomplete-here
(pcmpl-linux--systemd-units context "--state" "active")))
(_ (pcomplete-here
(completion-table-in-turn
(pcmpl-linux--systemd-units context "--all")
(pcomplete-entries)))))))))