Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions Completion/Unix/Command/_shutdown
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
#compdef shutdown

local -a args
local state

if [[ -d /etc/systemd ]]; then
_arguments \
_arguments -C \
'--help[display usage information]' \
'(-H --halt)'{-H,--halt}'[halt the machine]' \
'(-P --poweroff -h)'{-P,--poweroff,-h}'[power-off the machine (default)]' \
'(-r --reboot)'{-r,--reboot}'[reboot the machine]' \
"(--no-wall)-k[don't shutdown, just write wall message]" \
"(-k)--no-wall[don't send a wall message]" \
'-c[cancel pending shutdown]' \
'1: :_guard "^-*" "time (now/hh\:mm/+mins)"' \
'1:time:->time' \
'*:warning message'

case $state in
time)
_values -s ' ' 'shutdown time' \
'now[shutdown immediately]' \
'+1[shutdown in 1 minute]' \
'+5[shutdown in 5 minutes]' \
'+10[shutdown in 10 minutes]'
;;
esac

return
fi

Expand All @@ -23,7 +35,7 @@ case $OSTYPE in
'-r[reboot the system]'
'-k[kick everybody off]'
'-n[prevent file system cache from being flushed]'
'1: :_guard "^-*" "time (now/hh\:mm/+mins)"'
'1:time:->time'
'*:warning message'
)
;|
Expand Down Expand Up @@ -74,4 +86,14 @@ case $OSTYPE in
;;
esac

_arguments $args
_arguments -C $args

case $state in
time)
_values -s ' ' 'shutdown time' \
'now[shutdown immediately]' \
'+1[shutdown in 1 minute]' \
'+5[shutdown in 5 minutes]' \
'+10[shutdown in 10 minutes]'
;;
esac