aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--%HOME%/.bash_profile11
1 files changed, 7 insertions, 4 deletions
diff --git a/%HOME%/.bash_profile b/%HOME%/.bash_profile
index 317adae..fb2b58f 100644
--- a/%HOME%/.bash_profile
+++ b/%HOME%/.bash_profile
@@ -2,10 +2,15 @@
echo "Welcome to $( hostname )"
+kill_ssh_agent() {
+ [ -n "${SSH_AGENT_PID:+x}" ] && kill "$SSH_AGENT_PID"
+ local output_path="$HOME/.ssh_agent.sh"
+ rm -f -- "$output_path"
+}
+
spawn_ssh_agent() {
# This spawns ssh-agent and exports its variables to ~/.ssh_agent.sh,
# to be used in cron jobs and such.
- local rm_ssh_agent
local output_path="$HOME/.ssh_agent.sh"
[ -z "${SSH_AGENT_PID:+x}" ] \
&& command -v ssh-agent > /dev/null 2>&1 \
@@ -15,9 +20,7 @@ spawn_ssh_agent() {
&& source "$output_path" > /dev/null \
&& [ -n "${SSH_AGENT_PID:+x}" ] \
&& echo "Spawned ssh-agent with PID: $SSH_AGENT_PID." \
- && command -v printf > /dev/null 2>&1 \
- && rm_ssh_agent="$( printf -- 'kill %q' "$SSH_AGENT_PID" )" \
- && trap "$rm_ssh_agent" EXIT
+ && trap kill_ssh_agent EXIT
}
spawn_ssh_agent