Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: shutdown completion
- X-seq: zsh-workers 42568
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: shutdown completion
- Date: Fri, 30 Mar 2018 13:02:18 +0200
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1522418798; bh=TME650NFyq+YJZSQp80lR7/obTtKnRNOMWVSsblVLvA=; h=From:To:Subject:Date:From:Subject; b=hp3yWSipon6SgdW8xlAwzxs7JwnV6lRMyN3tEOKg6gql44y9CvihAdFvLglWYmSfmJS9vjkmjLUmRz0s+JvOVP1MdQ2cUPi3NuipjPPFcix7KJ4Hevd40Y87nEHBQcBXFq2TJWxrVbNHgQztx2gFhZbhEv9PzWW6R2sPwZFxW70nkkMbiiHL5dUNvo8x2iQipxZIYsV9F5I/SlGFz+oVhMW/LgcoSdJyxq+xDbUc7wZ1cKgDrkN+RmIUWfcUb/75casdP8LmEmWXwQc4wfOlJrng/0/1T58NvqvtCSTcAbACY3LqofbBRBLHKPfKIHiaHCnqVknPuY2IDmOrqauOGA==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author