From b02375c09f72208356bc2590d379193c6d15fc9f Mon Sep 17 00:00:00 2001 From: Joe Bloggs Date: Mon, 7 Jul 2014 00:47:52 +0100 Subject: [PATCH] Add _apt-key Completion for linux apt-key command. --- src/_apt-key | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/_apt-key diff --git a/src/_apt-key b/src/_apt-key new file mode 100644 index 0000000..879a557 --- /dev/null +++ b/src/_apt-key @@ -0,0 +1,39 @@ +#compdef apt-key=gpg + +local -a args reply matchany keycomp keyfile advopts + +# matches any word +matchany=(/$'[^\0]##\0'/) +# key file completion +keyfile=($matchany ':file:file:_files') +# key completion +function _apt_keys() +{ + local expl keys + local -a disp + keys=$(apt-key list | grep 'pub' | colrm 1 12 | colrm 9) + _wanted keys expl 'apt keys' compadd "$@" "$disp[@]" - "${(f)keys}" +} +keycomp=(/$'[A-F0-9]##\0'/ ":key:key:_apt_keys") +advopts=( \( $matchany ':option:option:{compset -n 2;_dispatch -command- gpg}' \) \# ) +#_dispatch $cmd:t $cmd $cmd:t -default- && ret=0 +args=$matchany +_regex_words command "command" \ + 'add:add the key contained in file (use \"-\" for stdin):$keyfile' \ + 'del:remove a key:$keycomp' \ + 'export:output a key:$keycomp' \ + 'exportall:output all trusted keys.' \ + 'update:update keys using the keyring package.' \ + 'net-update:update keys using the network.' \ + 'list:list keys.' \ + 'finger:list fingerprints.' \ + 'adv:pass advanced options to gpg (download key).:$advopts' +args+=("$reply[@]") + +_regex_arguments _apt-key "${args[@]}" + +_apt-key "$@" + +# Local Variables: +# mode:shell-script +# End: