Browse Source

zshrc: use gpg for ssh-agent

master
Skia 6 months ago
parent
commit
692a6e1211
1 changed files with 3 additions and 20 deletions
  1. +3
    -20
      .zshrc

+ 3
- 20
.zshrc View File

@@ -44,29 +44,12 @@ bindkey "^[[5~" up-line-or-history
bindkey "^[[6~" down-line-or-history
bindkey "b" backward-word

# ssh-agent
SSH_ENV="$HOME/.ssh/environment"
export SSH_AUTH_SOCK="/run/user/$(id -u)/gnupg/S.gpg-agent.ssh"

function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
}

# Source SSH settings, if applicable

if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
if ! [ -S "$SSH_AUTH_SOCK" ]; then
gpg-agent --enable-ssh-support --daemon
fi


case $TERM in
xterm*)
precmd () {print -Pn "\e]0;%n@%m: %~\a"}

Loading…
Cancel
Save