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=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18102 invoked from network); 3 Jun 2020 00:04:42 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 3 Jun 2020 00:04:42 -0000 Received: (qmail 28966 invoked by alias); 3 Jun 2020 00:04:29 -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: 24895 Received: (qmail 24340 invoked by uid 1010); 3 Jun 2020 00:04:29 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f42.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.166.42):SA:0(-2.0/5.0):. Processed in 3.866456 secs); 03 Jun 2020 00:04:29 -0000 X-Envelope-From: mikachu@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.166.42 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:in-reply-to:references:from:date :message-id:subject:to:cc; bh=NVb2n2idG67zoQzaK1HfN7VPfSF2K2uO0OcXhio6EIk=; b=bnGGSw4NTolMYW+1LRl6izrwxxIF3hEbbTWwbydeNy/+KZvSEFFzRe0R+ytayDXJ1t FRE3/+TNHSKTCcaZioZSuCvTpQFR3mFobh9+uvdx0Lxym6pmoLjcWV5nL867u1oY727p WOeaNF++VONW2xuk7d/zRf/bObFQVsRHMUXEQLZIXgzkZT2PdjM3kFm1W9zU/XjKUmbd BKW0BEXy5tTMAqFE1//RYz01qXm5Uad4lzSbl5/vEwNczkURGvfjlo6rMML9h8JfplxD 0rXIk0kceeX9yV5qe3bSoJI3O/JaNrfAFwMSwZ+r1Msjpen5RN74cNfV8WaEgoEXySdZ hzAg== X-Gm-Message-State: AOAM533BZWGn4fVsUvqyUC9E6qmSeDG5dny5HZj4o70rVK7b3jeQ73zt T37KjbrAW514mpEb9FFJKT2vvLEvVbrDIVqfJdu/ew== X-Google-Smtp-Source: ABdhPJz/v6s/LPuJVcwkYBdmbET0Km4aCiqopWUb5Hp/YWHaGC7ujeKtdocRoN+K/i+txvM1KsO/2hZ7SC1tPh99qlM= X-Received: by 2002:a05:6602:1243:: with SMTP id o3mr1490551iou.89.1591142632898; Tue, 02 Jun 2020 17:03:52 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Mikael Magnusson Date: Wed, 3 Jun 2020 02:03:51 +0200 Message-ID: Subject: Re: Cryptsetup completion To: Paul Ruane Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" On 6/2/20, Paul Ruane wrote: > 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. > > 11,12c11,12 > < '(-c --cipher)'{-c+,--cipher=}'[set cipher]:cipher specification' \ > < '(-h --hash)'{-h+,--hash=}'[hash algorithm]:hash algorithm' \ > --- >> '(-c --cipher)'{-c+,--cipher=}'[set cipher]:cipher >> specification:_ciphers' \ >> '(-h --hash)'{-h+,--hash=}'[hash algorithm]:hash algorithm:_hashes' \ > 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 | sed >> "s/^ //"' | \ >> while read -A line >> do >> cipher_list+=($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+=($line[1]) >> done >> >> _describe -t hashes 'hash' hash_list "$@" >> } One could also imagine these substitutions instead of forking twelve times: cipher_list=( ${${${(M)${(s:name:)${(M)${(f)"$(