From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3152 invoked by alias); 1 Jun 2015 22:25:48 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35356 Received: (qmail 861 invoked from network); 1 Jun 2015 22:25:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1433197180; bh=xnQTc2TjNi2vDtn0y40SvdJGeXYVSEtPrkuIqND+nfc=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=OI7QLOSmobD5w9vKg+rUT8ABFCSDj3KuM/sU/WT5DKVCdsRHN+Uq/fqCuvjaC9ByfQPO9d7b0m3fcAqqXt+PI5gHjf4tG/boibbQaSxymJUJZTFbao6ivCuvXfGzY5jPMdQeSrChNwQ7VKR18/2/K7aTShB+7d/B/4rgRrLZfAOhmUHUM1pNn36tPBTeg13F68FSSnecDdrz5VpiS/q6fiirmWkt8qnNZq/MZUHT8qCK8B8F3KXjk6i4ewVrnmpFTW4H9UF/m9Gn8liBCIJFtHBsGu2na9lujvbknfkeusCCfJN0B93PMmkHg7cbpwrMbP3LhOzjXMNxKI561TL9Ow== X-Yahoo-Newman-Id: 173661.51540.bm@smtp148.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: FaT1Vl8VM1l4Y43d.4OmbiO.JisYoz4R98K17A_icZpEddp djQ2kC8.ad5F4kZlt596FlIBYN2E7gPPCo7jTpxJ4Mrmz4GKT9znon7tct7T 4vgmFfR630.TcrBceet4O0_3Vnc6RVzgpksscj8gTHP9z.QniyqbD7vjOWdO itmkBysEK_O5kPriknOYLxenZYUkzC4DlAcXD70ict_d_m5_4LofT.hGHzDj UbkwHO2obWE5rREbdWLrndImT.fP8MSfjHDdKn5z6A_flFCtXerWGk02PEpO 981.bApK5z2GKfmY0tdLUqTlpJs28GSsVfr5d3Gcl_l8asZS5swboz48x87V tvN0gpejXwkK.mK36fMNk4_3UkVSEvRTOgmUHyzPd9vVtsfJ_uzH.jHC.hlV 323grcHqED.EOab69Oe7.mcBoos8DQ0J28xHeeFNF1___eduvRPGPHnnUyQv zmOyVjLmtvPm4Se65_d62HW0eIzMOvgcmDXvWO5Lj.G5bhacg5t_cN.LYPh5 lgH4ZAx5V57shBMYmpSHV.5dJN9BXQ_bb X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <20150523101555.GF1889@tarsus.local2> From: Oliver Kiddle References: <20150523101555.GF1889@tarsus.local2> To: zsh-workers@zsh.org Subject: Re: [PATCH] completion: Add FreeBSD's watch(1) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18591.1433197178.1@thecus.kiddle.eu> Date: Tue, 02 Jun 2015 00:19:39 +0200 Message-ID: <18592.1433197179@thecus.kiddle.eu> On 23 May, Daniel Shahaf wrote: > We may need a _ttys function. That seems like a good idea. The pattern for ttys has been duplicated a few times and this will make it easier if the system variations in the device names is more peculiar than we have so far assumed. This _ttys function allows the /dev/ prefix to be optional, required or stripped. I think there's a bug somewhere in the hidden prefix handling that this shows up, however. Oliver diff --git a/Completion/Unix/Command/_gdb b/Completion/Unix/Command/_gdb index 48c9d65..f387c87 100644 --- a/Completion/Unix/Command/_gdb +++ b/Completion/Unix/Command/_gdb @@ -5,17 +5,19 @@ local cur="$words[CURRENT]" prev w list ret=1 expl [[ "$PREFIX" = --* ]] && _arguments -- '*=(CORE|SYM)FILE:core file:_files' \ '*=EXECFILE:executable:_files -g \*\(-\*\)' \ - '*=TTY:terminal device:compadd /dev/tty\*' && return 0 + '*=TTY:terminal device:_ttys' && return 0 if compset -P '-(cd|directory)='; then _files -/ elif compset -P '-tty='; then - _wanted devices expl 'terminal device' compadd - /dev/tty* + _wanted devices expl 'terminal device' _ttys elif compset -P '-(exec|se)='; then _description files expl executable _files "$expl[@]" -g '*(-*)' elif compset -P '-(symbols|core|command)='; then _files +elif compset -P '--pid='; then + _pids elif [[ "$PREFIX" = -* ]]; then _tags options while _tags; do diff --git a/Completion/Unix/Command/_last b/Completion/Unix/Command/_last index 706d82f..f198e0f 100644 --- a/Completion/Unix/Command/_last +++ b/Completion/Unix/Command/_last @@ -9,7 +9,7 @@ for pattern arg in \ '((free|net|open)bsd*|darwin*|dragonfly*|linux-gnu)' '-h[limit sessions by hostname]:host:_hosts' \ '((free|open)bsd*|linux-gnu)' '-s[report duration in seconds]' \ '(freebsd*|openbsd*)' '-d[limit sessions to those active at snapshot time]:time ([[CC]YY][MMDD]hhmm[.SS])' \ - '((net|free|open)bsd*|darwin*|dragonfly*)' '-t[limit sessions by tty]:tty:compadd -a ttys' \ + '((net|free|open)bsd*|darwin*|dragonfly*)' '-t[limit sessions by tty]:tty:_ttys -D' \ 'openbsd*' '-c[calculate total time]' \ '^darwin*' '-f[specify account file]:file:_files' \ '(solaris*|linux-gnu|freebsd*|openbsd*)' '-n[specify number of lines to show]:number' \ @@ -45,7 +45,7 @@ case $OSTYPE in esac if [[ $OSTYPE = (linux-gnu|solaris*) ]]; then - args+=( '*:arg: _alternative "users:user:_users" "ttys:tty:compadd -a ttys"' ) + args+=( '*:arg: _alternative "users:user:_users" "ttys:tty:_ttys -d" "ttys:tty:(reboot)"' ) else args+=( '*:user:_users' ) fi diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep index d3dcd18..0b7d23d 100644 --- a/Completion/Unix/Command/_pgrep +++ b/Completion/Unix/Command/_pgrep @@ -13,7 +13,7 @@ arguments=('-P[parent process id]:parent process id:->ppid' '-M[extract the name list from the specified core]:files:_files' '-N[extract the name list from the specified system]:files:_files' '-s[match only session id]:session id:->sid' - '-t[match only controlled by terminal]:terminal device:->tty' + '-t[match only controlled by terminal]:terminal device:_sequence _ttys -d' '-T[match only in processes specified routing table in rtable]' '-u[match only effective user id]:user:_users' '-U[match only real user id]:user:_users' @@ -69,12 +69,6 @@ arguments=( ${(M)arguments:#(|\*)(|\(*\))-[$optchars]*} _arguments -C -s -w $arguments && ret=0 case $state in - (tty) - local -a ttys - ttys=( /dev/tty*(N) /dev/pts/*(N) ) - _sequence -s , _wanted tty expl 'terminal device' compadd - ${ttys#/dev/} - ;; - (sid) if [[ $OSTYPE == openbsd* ]]; then break diff --git a/Completion/Unix/Command/_ps b/Completion/Unix/Command/_ps index e557b27..6f67f79 100644 --- a/Completion/Unix/Command/_ps +++ b/Completion/Unix/Command/_ps @@ -31,7 +31,7 @@ args=( '*-G+[select processes by real group]:group:_sequence -s , _groups' '*-g+[select processes by effective group or session]:group:_sequence -s , _groups' '*-s+[select processes by session leaders]:session leader:_sequence -s , _pids' - '*-t+[select processes by attached terminal]:tty:_sequence -s , compadd - /dev/pts/<->(N\:s/\\/dev\\//) /dev/tty*(N\:t)' + '*-t+[select processes by attached terminal]:tty:_sequence -s , _ttys -D' '*-u+[select processes by effective user]:user:_sequence -s , _users' '*-U+[select processes by real user]:user:_sequence -s , _users' '-o+[specify output format]:property:_sequence -s , _ps_props -' @@ -163,8 +163,7 @@ if (( CURRENT > 1 )) && [[ $OSTYPE != solaris* || ( $OSTYPE = linux-gnu && $word *J) _sequence _jails -0 && return ;; *[MNW]) _files && return ;; *t) - _wanted -C option-t-1 ttys expl tty _sequence -s , \ - compadd - /dev/pts/<->(N\:s/\\/dev\\//) /dev/tty*(N\:t) && return + _wanted -C option-t-1 ttys expl tty _sequence -s , _ttys -D && return ;; *p) _wanted -C option-p-1 processes expl 'process ID' _sequence -s , _pids && return;; *U) _wanted -C option-U-1 users expl user _sequence -s , _users && return ;; diff --git a/Completion/Unix/Type/_ttys b/Completion/Unix/Type/_ttys new file mode 100644 index 0000000..5e55985 --- /dev/null +++ b/Completion/Unix/Type/_ttys @@ -0,0 +1,19 @@ +#autoload + +# Options: +# +# -d strip /dev/ prefix from matches +# -D matches allowed with or without /dev/ prefix + +local -a ttys expl pre +local stripdev optdev + +zparseopts -D -K -E d=stripdev D=optdev + +ttys=( /dev/tty?*(N) /dev/pts/^ptmx(N) ) +ttys=( ${ttys#/dev/} ) +[[ -z $stripdev ]] && pre=( -p /dev/ ) + +_description ttys expl 'tty' +[[ -n $optdev ]] && compadd "$@" "$expl[@]" -M 'r:|/=* r:|=*' -a ttys && return +compadd "$@" "$expl[@]" "$pre[@]" -M 'r:|/=* r:|=*' -a ttys