zsh-workers
 help / color / mirror / code / Atom feed
From: Christian Neukirchen <chneukirchen@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] new completion for "sv"
Date: Mon, 06 Oct 2014 11:54:46 +0200	[thread overview]
Message-ID: <87vbnxseu1.fsf@gmail.com> (raw)
In-Reply-To: <20141005200437.GE58824@wanderlust.lan.mitsi.com> (fREW Schmidt's message of "Sun, 5 Oct 2014 15:04:37 -0500")

[-- Attachment #1: Type: text/plain, Size: 450 bytes --]

fREW Schmidt <frioux@gmail.com> writes:

> Also, I forgot to mention, please CC me on replies as I am not on the
> list.

For comparising, I attached the version I wrote for myself.

I think only the first command should parse as a command.
Also I support first-char completion, perhaps that could be merged.

I'm not sure where $SVDIR is from, perhaps it should have a default
value.  Also, I complete any service directory if it contains a slash.


[-- Attachment #2: _sv --]
[-- Type: application/octet-stream, Size: 972 bytes --]

#compdef sv

# completion for runit sv(1)
# Christian Neukirchen <chneukirchen@gmail.com>
# runit 2.1.1, services in /var/service are completed by default

local ret=1 services

_arguments \
    '-v[verbose]' \
    '-w[wait]:seconds' \
    '1: :->cmds' \
    '*:: :->args' && ret=0

case $state in
cmds)
    _values "sv command" \
        status \
        up \
        down \
        once \
        pause cont hup alarm interrupt quit 1 2 term kill \
        exit
    # above allow one-character shortcuts, complete these
    [[ $words[CURRENT] = [sudopchaiq12tke] ]] ||
    _values "sv command" \
        start \
        stop \
        restart \
        shutdown \
        force-stop \
        force-reload \
        force-restart \
        force-shutdown \
        check
    ret=0;;
args)
    services=( /var/service/*(-/N:t) )
    (( $#services )) && _values services $services && ret=0
    [[ $words[CURRENT] = */* ]] && _directories && ret=0
    ;;
esac

return $ret

[-- Attachment #3: Type: text/plain, Size: 77 bytes --]


-- 
Christian Neukirchen  <chneukirchen@gmail.com>  http://chneukirchen.org

  reply	other threads:[~2014-10-06  9:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-05 20:01 fREW Schmidt
2014-10-05 20:04 ` fREW Schmidt
2014-10-06  9:54   ` Christian Neukirchen [this message]
2014-10-06 19:37 ` Oliver Kiddle
2014-10-07 13:20   ` fREW Schmidt
2014-10-07 15:28     ` Oliver Kiddle
2014-10-07 16:03       ` fREW Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vbnxseu1.fsf@gmail.com \
    --to=chneukirchen@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).