From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24579 invoked from network); 3 Jun 2020 11:20:07 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 3 Jun 2020 11:20:07 -0000 Received: (qmail 19076 invoked by alias); 3 Jun 2020 11:19:56 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24898 Received: (qmail 24006 invoked by uid 1010); 3 Jun 2020 11:19:56 -0000 X-Qmail-Scanner-Diagnostics: from mail-ot1-f50.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25828. spamassassin: 3.4.4. Clear:RC:0(209.85.210.50):SA:0(-1.4/5.0):. Processed in 2.477179 secs); 03 Jun 2020 11:19:56 -0000 X-Envelope-From: oniony@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.210.50 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=gj5RM1nab69F5OOGpgrUADmV9qPQBn8sgTvGt0OY/M8=; b=P193Z3YDy6T8A2oBd0JryV4udhWFekrcfugmdCepwxcjqhOp/YkLR5mzKnpHer6hHD kXKkW5yIuZW01+O1YwkF8L3VYaSwM9EBog2ISXFdic4QBG0IhvKIMjFncy6zIV2m8GDv hYQhtgPzRZ9lWI6Qp+zkKLAmdpopXn2JLj6XakMZqhNgZyQFhv6EoZjyFjfAuIyuKoyQ oxQGjTZxLGGsRI/KcTre2/akMSaalpEiDW0dHb7AGjLhKvRy5n4HcxAAGDksLTM+WIsU bhVMF7mBamqE7h14T3yD5YXTDMecRE453Bx75Ss0zrD4uGyZdi3JsxgMCQo3ROI6ksgs 0AVw== X-Gm-Message-State: AOAM531WtCHAAW3nJfPB0JMQvfW8lR119z9hwu0z+fisJS7aUqo+SbBj inuv+Owvj+dNKAjXNlUjN7kqVI+m/UN4ac06I94= X-Google-Smtp-Source: ABdhPJzjmTwwRRgMVUMHXrl6hGtEvRmTDBcjeSvA1R2zJlEDCd37ehqytZKWb+PisDKZX1nxlf0WuvepU9WxLX3ybuQ= X-Received: by 2002:a9d:5612:: with SMTP id e18mr2625611oti.24.1591183160607; Wed, 03 Jun 2020 04:19:20 -0700 (PDT) MIME-Version: 1.0 References: <20200603005555.304cca04@tarpaulin.shahaf.local2> In-Reply-To: <20200603005555.304cca04@tarpaulin.shahaf.local2> From: Paul Ruane Date: Wed, 3 Jun 2020 12:19:09 +0100 Message-ID: Subject: Re: Cryptsetup completion To: Daniel Shahaf Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for the detailed reply. I'll have a crack at making these changes and integrating Mikael's enlightening parameter expansion approach rather than my primitive piping. Paul On Wed, 3 Jun 2020 at 01:56, Daniel Shahaf wrote: > > Paul Ruane wrote on Tue, 02 Jun 2020 17:17 +0100: > > Hi, > > > > For my own system I have modified the Zsh completion of cryptsetup to > > include completion of the hash and cipher based upon those declared > > available in /proc/crypto. I thought this might be useful for other > > users, too, so I have included my changes below for your > > consideration. > > > > Thanks. > > The helper functions are in the global namespace so they should have > names that are less likely to clash. Also, they aren't specific to > cryptsetup, so we could break them out to separate, autoloadable files > (with "#autoload" on their first line rather than "#compdef foo"). > > Would you be interested in updating the patch along these lines? It'd > be best to do so by using zsh from git, but you needn't build zsh for > that (you can simply clone the git repository and, for testing, set > =C2=ABfpath=3D( /path/to/zsh/Completions/**/*(/) )=C2=BB prior to running= compinit.). > > Cheers, > > Daniel > > P.S. For future reference, always pass the -u option to diff(1), > otherwise the patches cannot be applied except to the very same version > of the original file. > > > > 11,12c11,12 > > < '(-c --cipher)'{-c+,--cipher=3D}'[set cipher]:cipher specification'= \ > > < '(-h --hash)'{-h+,--hash=3D}'[hash algorithm]:hash algorithm' \ > > --- > > > '(-c --cipher)'{-c+,--cipher=3D}'[set cipher]:cipher specification:= _ciphers' \ > > > '(-h --hash)'{-h+,--hash=3D}'[hash algorithm]:hash algorithm:_hashe= s' \ > > 157a158,183 > > > > > > _ciphers() { > > > typeset -a cipher_list > > > local line > > > > > > _call_program grep 'grep "^\(name\|type\)\s\+:" /proc/crypto | grep -= B1 "^type\s\+:\s\+cipher" | grep "^name\s\+:" | cut -d ":" -f 2 | uniq | se= d "s/^ //"' | \ > > > while read -A line > > > do > > > cipher_list+=3D($line[1]) > > > done > > > > > > _describe -t ciphers 'cipher' cipher_list "$@" > > > } > > > > > > _hashes() { > > > typeset -a hash_list > > > local line > > > > > > _call_program grep 'grep "^\(name\|type\)\s\+:" /proc/crypto | grep -= B1 "^type\s\+:\s\+shash" | grep "^name\s\+:" | cut -d ":" -f 2 | uniq | sed= "s/^ //"' | \ > > > while read -A line > > > do > > > hash_list+=3D($line[1]) > > > done > > > > > > _describe -t hashes 'hash' hash_list "$@" > > > } > > > > Paul >