blob: fa9208816c8d09cf52b3fadca42ce982b88fb378 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/usr/bin/env bash
# Copyright (c) 2018 Egor Tensin <Egor.Tensin@gmail.com>
# This file is part of the "Linux/Cygwin environment" project.
# For details, see https://github.com/egor-tensin/linux-home.
# Distributed under the MIT License.
kill_ssh_agent() {
[ -n "${SSH_AGENT_PID:+x}" ] && kill "$SSH_AGENT_PID"
}
spawn_ssh_agent() {
local output
[ -z "${SSH_AGENT_PID:+x}" ] \
&& command -v ssh-agent > /dev/null 2>&1 \
&& output="$( ssh-agent -s )" \
&& eval "$output" > /dev/null \
&& [ -n "${SSH_AGENT_PID:+x}" ] \
&& echo "Spawned ssh-agent with PID: $SSH_AGENT_PID." \
&& trap kill_ssh_agent EXIT
}
alias ssh-copy-id='ssh-copy-id -i'
|