dotfiles/.config/zsh/functions/ssh-sign
tastytea c2f45d5661
Improve ssh-sign function
Add -h option, don't require argument
2022-04-08 22:26:12 +02:00

19 lines
442 B
Bash
Executable File

#!/usr/bin/env zsh
# Sign files with SSH
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
autoload -U die
zmodload zsh/zutil
local -a keyfile=(-f ~/.ssh/id_ed25519)
local -a namespace=(-n file)
local -a help=()
zparseopts -D -K -- f:=keyfile n:=namespace h=help
if [[ ${#help} -ne 0 ]]; then
print "Usage: ${0} [-h] [-f KEYFILE] [-n NAMESPACE] <file> …"
return 0
fi
ssh-keygen -Y sign -f ${keyfile[2]} -n ${namespace[2]} ${@}