zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: shutdown completion
@ 2018-03-30 11:02 Oliver Kiddle
  2018-04-03  9:52 ` Jun T
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2018-03-30 11:02 UTC (permalink / raw)
  To: Zsh workers

There's a shutdown completion in the zsh-completions project but it is
system specific. This one handles the major BSDs and Solaris. On Linux,
shutdown tends to come from the init system. systemd is handled
otherwise you only get the most common BSD-style options.

Oliver

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: shutdown completion
  2018-03-30 11:02 PATCH: shutdown completion Oliver Kiddle
@ 2018-04-03  9:52 ` Jun T
  2018-05-19  8:57   ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Jun T @ 2018-04-03  9:52 UTC (permalink / raw)
  To: zsh-workers

Add support for macOS.

Are there any linux systems (not using systemd) where
'-p' (lower case 'p') means 'turn off power after shutdown'?



diff --git a/Completion/Unix/Command/_shutdown b/Completion/Unix/Command/_shutdown
index 1ac6e61ba..9726182a0 100644
--- a/Completion/Unix/Command/_shutdown
+++ b/Completion/Unix/Command/_shutdown
@@ -17,10 +17,9 @@ if [[ -d /etc/systemd ]]; then
 fi
 
 case $OSTYPE in
-  *bsd*|dragonfly*|linux*)
+  *bsd*|dragonfly*|linux*|darwin*)
     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]'
@@ -28,6 +27,11 @@ case $OSTYPE in
       '*:warning message'
     )
   ;|
+  *bsd*|dragonfly*|linux*)
+    args=(
+      '-p[turn off power after shutdown]'
+    )
+  ;|
   (net|open)bsd*)
     args+=(
       '-d[cause system to perform a dump]'
@@ -48,6 +52,13 @@ case $OSTYPE in
       '-D[prevent shutdown from detaching from the tty]'
     )
   ;;
+  darwin*)
+    args+=(
+      '-o[execute halt or reboot instead of sending a signal to launchd]'
+      '-s[put the system to sleep]'
+      '-u[with -h, wait 5 minutes before removing power]'
+    )
+  ;;
   solaris2.<11->) args=( '(-i)-r[reboot]' ) ;&
   solaris*)
     args+=(



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: shutdown completion
  2018-04-03  9:52 ` Jun T
@ 2018-05-19  8:57   ` Oliver Kiddle
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver Kiddle @ 2018-05-19  8:57 UTC (permalink / raw)
  To: zsh-workers

On 3 Apr, Jun T wrote:
>
> Are there any linux systems (not using systemd) where
> '-p' (lower case 'p') means 'turn off power after shutdown'?

None of the linux systems I've looked at have -p. -P does occur.
More significantly, the patch uses args= where args+= was needed and
loses a bunch of options.

Oliver

diff --git a/Completion/Unix/Command/_shutdown b/Completion/Unix/Command/_shutdown
index 9726182a0..4119502fb 100644
--- a/Completion/Unix/Command/_shutdown
+++ b/Completion/Unix/Command/_shutdown
@@ -27,8 +27,8 @@ case $OSTYPE in
       '*:warning message'
     )
   ;|
-  *bsd*|dragonfly*|linux*)
-    args=(
+  *bsd*|dragonfly*)
+    args+=(
       '-p[turn off power after shutdown]'
     )
   ;|


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-19  8:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-30 11:02 PATCH: shutdown completion Oliver Kiddle
2018-04-03  9:52 ` Jun T
2018-05-19  8:57   ` Oliver Kiddle

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).