Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Cryptsetup completion

On Wed, 3 Jun 2020 at 01:56, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:

> 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

I have renamed these with prefix "_crypto". I noticed commands and
types are now split into their respective directories so I have placed
them accordingly.

> that (you can simply clone the git repository and, for testing, set
> «fpath=( /path/to/zsh/Completions/**/*(/) )» prior to running compinit.).

I was unable to get the fpath with the globbing to work. I ended up
using "fpath=( /home/paul/projects/zsh/Completion )". Even so I had
some errors ("_arguments:comparguments:393: too many arguments")
completing with many commands, not just cryptsetup, but I assume that
this is some incompatibility between my 5.8 and HEAD.

I've used a slightly modified version of Mikael's parameter expansion
to eliminate the need to fork processes.

The new patch--in correct format :)--is here:

diff --git a/Completion/Linux/Command/_cryptsetup
index 45159d0be..3e3bd5ba0 100644
--- a/Completion/Linux/Command/_cryptsetup
+++ b/Completion/Linux/Command/_cryptsetup
@@ -8,8 +8,8 @@ _arguments -s \
   '(-v --verbose)'{-v,--verbose}'[enable verbose mode]' \
   '--debug[show debug messages]' \
   '--debug-json[show debug messages including JSON metadata]' \
-  '(-c --cipher)'{-c+,--cipher=}'[set cipher]:cipher specification' \
-  '(-h --hash)'{-h+,--hash=}'[hash algorithm]:hash algorithm' \
+  '(-c --cipher)'{-c+,--cipher=}'[set cipher]:cipher
specification:_crypto_ciphers' \
+  '(-h --hash)'{-h+,--hash=}'[hash algorithm]:hash algorithm:_crypto_hashes' \
   '(-y --verify-passphrase)'{-y,--verify-passphrase}'[query for
password twice]' \
   '(-d --key-file)'{-d+,--key-file=}'[set keyfile]:key file:_files' \
   '--master-key-file=[set master key]:key file:_files' \
diff --git a/Completion/Linux/Type/_crypto_ciphers
new file mode 100644
index 000000000..ab9138a11
--- /dev/null
+++ b/Completion/Linux/Type/_crypto_ciphers
@@ -0,0 +1,7 @@
+cipher_list=( ${${${(M)${(s:name:)${(M)${(f)"$(</proc/crypto)"}:#(name|type)*}}:#*:
cipher*}#*: }%% *} )
+_describe -t ciphers 'cipher' cipher_list
+return ret
diff --git a/Completion/Linux/Type/_crypto_hashes
new file mode 100644
index 000000000..56b06b5f0
--- /dev/null
+++ b/Completion/Linux/Type/_crypto_hashes
@@ -0,0 +1,7 @@
+hash_list=( ${${${(M)${(s:name:)${(M)${(f)"$(</proc/crypto)"}:#(name|type)*}}:#*:
shash*}#*: }%% *} )
+_describe -t hashes 'hash' hash_list
+return ret


Messages sorted by: Reverse Date, Date, Thread, Author