Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Completion: Improve _watch
- X-seq: zsh-workers 43895
- From: dana <dana@xxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: [PATCH] Completion: Improve _watch
- Date: Thu, 13 Dec 2018 19:32:54 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=nVFcmpv9bRccPkO4tpUu2Mt8t9ruforNS+QjdrBA6IM=; b=FNIIgzzUjhV+NbuwBhjtOJ6B1fANgG83oxTSV0648LqyaGKLnJ8pTWmMPs/I18H4Vc ezpF6d4TNZRk9e2lOOlcjIfe7tDgPOh45fTtEs14ThQVbTwbBbzk2/cFgYRzRoS7Ku+F vuxHQwJshIOgboFgxesugT4tTwrCMzdv3zlv6vwZ6g1l5+I04MH/voS2pF9Sz3e5wYhL JJdTDmuDWVsh0qHZzVqRd+kFg0+m44rGjf49cjn/0DL9WfbPgVzfExE0qRVQsyk561g5 v05bw5Chmspd432eWfGTF7qmTFrPhGZ1eT/KEPEC5g3y1ym4cHsCiXZbGX0QPbaLBROV hL6Q==
- 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
Someone on IRC complained that the watch completion isn't very good
As far as i can tell it's pretty typical for people to quote the first operand
of the command only when it represents a shell command string (as in
`watch 'foo | grep bar'` — so i made it so that we choose between _cmdstring
and _normal depending on that quoting. Hopefully not too magic
dana
diff --git a/Completion/Unix/Command/_watch b/Completion/Unix/Command/_watch
index a8d29403f..fff3d56f6 100644
--- a/Completion/Unix/Command/_watch
+++ b/Completion/Unix/Command/_watch
@@ -1,9 +1,42 @@
#compdef watch
-# watch(1) has completely different semantics on freebsd compared to linux, hence:
-case $OSTYPE in
- (freebsd*|dragonfly*) _watch-snoop "$@";;
- (*) _default;;
+local variant ret=1
+local -a context line state state_descr
+local -A opt_args
+
+_pick_variant -r variant procps=procps $OSTYPE --version
+
+case $variant in
+ (procps)
+ _arguments -s -S -A '-*' : \
+ '(: * -)'{-h,--help}'[display help information]' \
+ '(: * -)'{-v,--version}'[display version information]' \
+ '(-b --beep)'{-b,--beep}'[beep on non-zero command exit]' \
+ '(-c --color)'{-c,--color}'[interpret ANSI color/style sequences]' \
+ '(-d --differences)'{-d-,--differences=-}'[highlight changes between updates]::how to highlight:(permanent)' \
+ '(-e --errexit)'{-e,--errexit}'[freeze updates on non-zero command exit]' \
+ '(-g --chgexit)'{-g,--chgexit}'[exit on command output change]' \
+ '(-n --interval)'{-n+,--interval=}'[specify update interval]:update interval (seconds) [2]' \
+ '(-p --precise)'{-p,--precise}'[run command at precise intervals]' \
+ '(-t --no-title)'{-t,--no-title}'[disable header]' \
+ '(-x --exec)'{-x,--exec}'[pass command to exec(2) instead of `sh -c`]' \
+ '(-)*::: :->cmd' \
+ && ret=0
+
+ [[ $state == cmd ]] &&
+ if
+ (( CURRENT == 1 )) &&
+ [[ $words[1] == (\"|\'|\$\')* ]] &&
+ [[ -z $opt_args[(i)(-x|--exec)] ]]
+ then
+ _cmdstring && ret=0
+ else
+ _normal && ret=0
+ fi
+ ;;
+ # watch(1) has completely different semantics on freebsd compared to linux, hence:
+ (freebsd*|dragonfly*) _watch-snoop "$@" && ret=0 ;;
+ (*) _default && ret=0 ;;
esac
-# NOTREACHED
+return ret
Messages sorted by:
Reverse Date,
Date,
Thread,
Author