From ff601692ec871fbbb719b379d9d38e0f0758ab90 Mon Sep 17 00:00:00 2001 From: XS Date: Thu, 2 Apr 2026 13:25:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(keyman):=20=E6=9B=B4=E6=96=B0=20GPG=20?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E7=9A=84=E7=94=A8=E6=B3=95=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E5=AF=86=E9=92=A5=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8F=90=E5=8F=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/keyman/keyman.plugin.zsh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/plugins/keyman/keyman.plugin.zsh b/plugins/keyman/keyman.plugin.zsh index 2fbd448c3..720826ba1 100644 --- a/plugins/keyman/keyman.plugin.zsh +++ b/plugins/keyman/keyman.plugin.zsh @@ -196,7 +196,7 @@ ${_km_cyan}GPG 命令:${_km_reset} usage_ssh_rm "Usage: keyman ssh rm " key_not_found "Key not found" # -- gpg quick-new -- - usage_gpg_quick_new "Usage: keyman gpg quick-new \"Name\" \"Email\" [expiry]" + usage_gpg_quick_new "Usage: keyman gpg quick-new \"Name\" \"Email\" [exp]" email_has_gpg_key "This email already has a GPG key:" confirm_create_new "Continue creating new key? (y/N) " creating_gpg_key "Creating GPG key..." @@ -735,8 +735,23 @@ _keyman() { ;; pub|priv|copy|fp|rm) local -a key_ids - key_ids=(${(f)"$(gpg --list-keys --with-colons 2>/dev/null \ - | awk -F: '/^uid/{print $10}; /^pub/{print $5}')"}) + key_ids=(${(f)"$(gpg --list-keys --with-colons 2>/dev/null | awk -F: ' + /^pub/ { keyid = $5 } + /^uid/ && keyid != "" { + uid = $10 + if (uid != "") { + print keyid ":" uid + n = index(uid, "<") + if (n > 0) { + email = substr(uid, n + 1) + p = index(email, ">") + if (p > 0) email = substr(email, 1, p - 1) + if (email != "") print email ":" uid + } + keyid = "" + } + } + ')"}) _describe 'GPG key ID or email' key_ids ;; esac