aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--%HOME%/.bash_profile24
-rw-r--r--%HOME%/.bash_utils/ssh.sh23
-rw-r--r--%HOME%/.bashrc3
3 files changed, 26 insertions, 24 deletions
diff --git a/%HOME%/.bash_profile b/%HOME%/.bash_profile
index fb2b58f..b42f274 100644
--- a/%HOME%/.bash_profile
+++ b/%HOME%/.bash_profile
@@ -2,25 +2,5 @@
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 output_path="$HOME/.ssh_agent.sh"
- [ -z "${SSH_AGENT_PID:+x}" ] \
- && command -v ssh-agent > /dev/null 2>&1 \
- && touch -- "$output_path" \
- && chmod 0600 -- "$output_path" \
- && ssh-agent -s > "$output_path" \
- && source "$output_path" > /dev/null \
- && [ -n "${SSH_AGENT_PID:+x}" ] \
- && echo "Spawned ssh-agent with PID: $SSH_AGENT_PID." \
- && trap kill_ssh_agent EXIT
-}
-
-spawn_ssh_agent
+command -v spawn_ssh_agent > /dev/null 2>&1 \
+ && spawn_ssh_agent
diff --git a/%HOME%/.bash_utils/ssh.sh b/%HOME%/.bash_utils/ssh.sh
new file mode 100644
index 0000000..fa92088
--- /dev/null
+++ b/%HOME%/.bash_utils/ssh.sh
@@ -0,0 +1,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'
diff --git a/%HOME%/.bashrc b/%HOME%/.bashrc
index 2b39b94..b23fc09 100644
--- a/%HOME%/.bashrc
+++ b/%HOME%/.bashrc
@@ -44,8 +44,6 @@ alias utc_iso='date --utc +"%Y-%m-%dT%H:%M:%SZ"'
# fixed in sed 4.3.
# Don't forget to uncomment once sed 4.3 becomes common.
-alias ssh-copy-id='ssh-copy-id -i'
-
alias cls='echo -en "\ec"'
alias copy='xclip -sel clip'
@@ -57,6 +55,7 @@ alias copy='xclip -sel clip'
[ -r "$HOME/.bash_utils/git.sh" ] && source "$HOME/.bash_utils/git.sh"
[ -r "$HOME/.bash_utils/os.sh" ] && source "$HOME/.bash_utils/os.sh"
[ -r "$HOME/.bash_utils/path.sh" ] && source "$HOME/.bash_utils/path.sh"
+[ -r "$HOME/.bash_utils/ssh.sh" ] && source "$HOME/.bash_utils/ssh.sh"
[ -r "$HOME/.bash_utils/mysql.sh" ] && source "$HOME/.bash_utils/mysql.sh"
[ -r "$HOME/.bash_utils/python.sh" ] && source "$HOME/.bash_utils/python.sh"