Last active
August 30, 2018 07:17
-
-
Save oflow/1305aaa256af5628c37b7954656c6e6a to your computer and use it in GitHub Desktop.
雑なsystemctl補完
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compdef _systemctl systemctl | |
function _systemctl() { | |
_arguments -C \ | |
'1: :(--help --version | |
enable disable start stop restart reload \ | |
cat status show kill \ | |
list-units list-timers list-unit-files list-sockets \ | |
daemon-reload \ | |
cancel list-jobs list-machines \ | |
try-restart try-reload-or-restart \ | |
isolate is-active is-failed is-enabled reset-failed \ | |
mask unmask link revert \ | |
edit get-default set-default \ | |
default rescue emergency kexec is-system-running \ | |
halt poweroff reboot suspend hibernate hybrid-sleep)' \ | |
'*:key:_list_unit_files' | |
_list_unit_files() { | |
local -a units | |
if [ "$(echo "$BUFFER" | grep " \(start\|restart\|reload\|stop\|status\|try-restart\|reload-or-restart\|reload-or-try-restart\|isolate\|kill\|is-active\|show\|reset-failed\|enable\|disable\|is-enabled\|load\)")" ]; then | |
units=(`ls /usr/lib/systemd/system/ | egrep '\.(service|socket|timer)'`) | |
_wanted key expl 'units' compadd $units | |
fi | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment