1
0
Fork 0

Add ssh-sign function

This commit is contained in:
tastytea 2022-04-08 20:11:49 +02:00
parent cac08403a8
commit 151f91fb24
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
3 changed files with 24 additions and 0 deletions

View File

@ -1 +1,2 @@
[[ -d "${ZDOTDIR}"/functions ]] && fpath+=( "${ZDOTDIR}"/functions )
[[ -d "${ZDOTDIR}"/completions ]] && fpath+=( "${ZDOTDIR}"/completions )

View File

@ -0,0 +1,9 @@
#compdef ssh-sign
_arguments '-f[keyfile]:filename:_files' '-n[namespace]:namespace:_ssh-sign_namespaces' '*:file:_files'
function _ssh-sign_namespaces()
{
local -a namespaces=(file email git "@$(dnsdomainname)")
_values "namespace" ${namespaces}
}

View File

@ -0,0 +1,14 @@
#!/usr/bin/env zsh
# Sign files with SSH
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
autoload -U die
[[ ${ARGC} -eq 0 ]] && die 1 "Usage: ${0} [-f KEYFILE] [-n NAMESPACE] <file> …"
zmodload zsh/zutil
local -a keyfile=(-f ~/.ssh/id_ed25519)
local -a namespace=(-n file)
zparseopts -D -K -- f:=keyfile n:=namespace
ssh-keygen -Y sign -f ${keyfile[2]} -n ${namespace[2]} ${@}