Move ssh and gpg from aliases to functions
This commit is contained in:
parent
f6da27428b
commit
59ef4d56d5
30
zshrc
30
zshrc
|
@ -310,11 +310,31 @@ alias ping6="ping6 -c 3"
|
||||||
## JOSM
|
## JOSM
|
||||||
alias josm="java -jar -Xmx2048M /opt/josm-tested.jar"
|
alias josm="java -jar -Xmx2048M /opt/josm-tested.jar"
|
||||||
|
|
||||||
## Keychain
|
# Keychain
|
||||||
# For SSH: If keychain doesn't exist, load it then source the file-sh
|
## For SSH {{{
|
||||||
alias ssh="[[ ! -f ~/.keychain/$HOST-sh ]] && keychain --agents ssh id_rsa; source ~/.keychain/$HOST-sh; ssh "
|
function ssh() {
|
||||||
# For GPG: If keychain doesn't exist, load it then source the file-sh-gpg
|
## If keychain exists, run ssh from default $PATH as usual
|
||||||
alias gpg="[[ ! -f ~/.keychain/$HOST-sh-gpg ]] && keychain --noask --systemd --agents gpg; source ~/.keychain/$HOST-sh-gpg; gpg "
|
if [ -f ~/.keychain/"${HOST}"-sh ]; then
|
||||||
|
command -p ssh "${*}"
|
||||||
|
else ## Otherwise, reload keychain and run ssh
|
||||||
|
keychain --agents ssh
|
||||||
|
source ~/.keychain/"${HOST}"-sh
|
||||||
|
command -p ssh "${*}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
## }}}
|
||||||
|
## For GPG {{{
|
||||||
|
function gpg() {
|
||||||
|
## If keychain exists, run gpg from default $PATH as usual
|
||||||
|
if [ -f ~/.keychain/"${HOST}"-sh-gpg ]; then
|
||||||
|
command -p gpg ${*}
|
||||||
|
else ## Otherwise, reload keychain and run gpg
|
||||||
|
keychain --agents gpg
|
||||||
|
source ~/.keychain/"${HOST}"-sh-gpg
|
||||||
|
command -p gpg ${*}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
## }}}
|
||||||
|
|
||||||
# ssh
|
# ssh
|
||||||
alias sshdev='ssh -o UserKnownHostsFile=/dev/null'
|
alias sshdev='ssh -o UserKnownHostsFile=/dev/null'
|
||||||
|
|
Loading…
Reference in New Issue