about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <okiddle@yahoo.co.uk>2018-03-30 16:23:59 +0200
committerOliver Kiddle <okiddle@yahoo.co.uk>2018-03-30 16:23:59 +0200
commit486297520fdcc0b8dd61fabb89f483d75d5c8d2a (patch)
tree09de06ae439c69e27952945dc39d283967799691
parent286b4c8b0cd855bc938d5ae8252d5273f37d9630 (diff)
downloadzsh-486297520fdcc0b8dd61fabb89f483d75d5c8d2a.tar.gz
zsh-486297520fdcc0b8dd61fabb89f483d75d5c8d2a.tar.xz
zsh-486297520fdcc0b8dd61fabb89f483d75d5c8d2a.zip
42568: new shutdown completion
-rw-r--r--ChangeLog2
-rw-r--r--Completion/Unix/Command/_shutdown61
2 files changed, 63 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9e287b5c4..500b6a644 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2018-03-30  Oliver Kiddle  <okiddle@yahoo.co.uk>
 
+	* 42568: Completion/Unix/Command/_shutdown: new completion
+
 	* 42569: Completion/Unix/Command/_lsof: improve completion after
 	-i and -s options
 
diff --git a/Completion/Unix/Command/_shutdown b/Completion/Unix/Command/_shutdown
new file mode 100644
index 000000000..1ac6e61ba
--- /dev/null
+++ b/Completion/Unix/Command/_shutdown
@@ -0,0 +1,61 @@
+#compdef shutdown
+
+local -a args
+
+if [[ -d /etc/systemd ]]; then
+  _arguments \
+    '--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)"' \
+    '*:warning message'
+  return
+fi
+
+case $OSTYPE in
+  *bsd*|dragonfly*|linux*)
+    args=(
+      '-h[halt the system after shutdown]'
+      '-p[turn off power after shutdown]'
+      '-r[reboot the system]'
+      '-k[kick everybody off]'
+      '-n[prevent file system cache from being flushed]'
+      '1: :_guard "^-*" "time (now/hh\:mm/+mins)"'
+      '*:warning message'
+    )
+  ;|
+  (net|open)bsd*)
+    args+=(
+      '-d[cause system to perform a dump]'
+      '-f[create /fastboot so that file systems will not be checked during the next boot]'
+    )
+  ;|
+  freebsd*|dragonfly*)
+    args+=(
+      '-o[execute halt or reboot instead of sending a signal to init]'
+    )
+  ;;
+  netbsd*)
+    args+=(
+      '-b[specify boot string to pass to reboot]:boot string'
+      '-v[enable verbose console messages]'
+      '-x[enable debug console messages]'
+      '-z[silence some console messages]'
+      '-D[prevent shutdown from detaching from the tty]'
+    )
+  ;;
+  solaris2.<11->) args=( '(-i)-r[reboot]' ) ;&
+  solaris*)
+    args+=(
+      '(-r)-i+[specify init-state]:init state:((0\:stop 1\:administrative s\:single\ user 5 6\:reboot))'
+      '-y[pre-answer yes to confirmation question]'
+      '-g+[specify grace period]:grace period (seconds) [60]'
+    )
+  ;;
+esac
+
+_arguments $args