Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] completion: Add FreeBSD's watch(1)



There's a completion for the linux watch(1) at
<https://github.com/zsh-users/zsh-completions/blob/master/src/_watch>.

We may need a _ttys function.

diff --git a/Completion/BSD/Command/_watch-freebsd b/Completion/BSD/Command/_watch-freebsd
new file mode 100644
index 0000000..7302051
--- /dev/null
+++ b/Completion/BSD/Command/_watch-freebsd
@@ -0,0 +1,21 @@
+#autoload
+
+# watch [-cinotW] [-f snpdev] [tty]
+
+# TODO: complete /dev/**/*(+isatty); the following also do so:
+#     Unix/Command/_pgrep
+#     Unix/Command/_gdb
+#     Unix/Command/_qemu
+#     Unix/Command/_ps
+#     Unix/Command/_last
+#     Unix/Type/_ps1234
+
+_arguments -w -S -s : \
+  "-c[Reconnect on close]" \
+  "-f:snp(4) device: " \
+  "-i[Force interactive mode even when stdout is not a tty]" \
+  "-n[Disable the ability to switch the watched tty interactively]" \
+  "-o[Reconnect on overflow]" \
+  "-t[Print date and time at start]" \
+  "-W[Allow write access to observed tty]" \
+  ":tty device: "
diff --git a/Completion/Unix/Command/_watch b/Completion/Unix/Command/_watch
new file mode 100644
index 0000000..7595dac
--- /dev/null
+++ b/Completion/Unix/Command/_watch
@@ -0,0 +1,9 @@
+#compdef watch
+
+# watch(1) has completely different semantics on freebsd compared to linux, hence:
+case $OSTYPE in
+  (freebsd*)  _watch-freebsd "$@"; return $?;;
+  (*)         return 1;;
+esac
+
+# NOTREACHED



Messages sorted by: Reverse Date, Date, Thread, Author