Improve ssh-sign function
Add -h option, don't require argument
This commit is contained in:
parent
151f91fb24
commit
c2f45d5661
@ -1,9 +1,13 @@
|
||||
#compdef ssh-sign
|
||||
|
||||
_arguments '-f[keyfile]:filename:_files' '-n[namespace]:namespace:_ssh-sign_namespaces' '*:file:_files'
|
||||
_arguments '-f[key file]:filename:_files' '-n[namespace]:namespace:_ssh-sign_namespaces' '*:file:_files' '-h[short help text]'
|
||||
|
||||
function _ssh-sign_namespaces()
|
||||
{
|
||||
local -a namespaces=(file email git "@$(dnsdomainname)")
|
||||
_values "namespace" ${namespaces}
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# End:
|
||||
|
8
.config/zsh/functions/ssh-sign
Normal file → Executable file
8
.config/zsh/functions/ssh-sign
Normal file → Executable file
@ -4,11 +4,15 @@
|
||||
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
|
||||
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]} ${@}
|
||||
|
Loading…
x
Reference in New Issue
Block a user