From e025a0cc72c9065e1ea2fe02289e8c78e1b34e79 Mon Sep 17 00:00:00 2001 From: Stefan Gaiselmann Date: Thu, 28 Jan 2021 12:56:59 +0100 Subject: [PATCH] Added check if find-agent is sourced and aliases to own scripts. --- bin/executable_find-agent.sh | 16 ++++++++++------ dot_bashrc.d/executable_08.alias | 5 +++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/executable_find-agent.sh b/bin/executable_find-agent.sh index 6156fa8..fc35065 100755 --- a/bin/executable_find-agent.sh +++ b/bin/executable_find-agent.sh @@ -4,9 +4,13 @@ # TODO: make keys configurable # -SSH_AUTH_SOCK=$(find /tmp/ -name 'agent*' -printf "%T@ %Tc %p\n" | sort -n | tail -1 | awk '{print $7}') -echo -e "$SSH_AUTH_SOCK" -export SSH_AUTH_SOCK -ssh-add ~/.ssh/daimler_rsa -ssh-add ~/.ssh/id_materna - +if [[ $_ = $0 ]]; then + echo "Script is a subshell, will source it: source $0" + exit 42 +else + SSH_AUTH_SOCK=$(find /tmp/ -name 'agent*' -printf "%T@ %Tc %p\n" | sort -n | tail -1 | awk '{print $7}') + echo -e "$SSH_AUTH_SOCK" + export SSH_AUTH_SOCK + ssh-add ~/.ssh/daimler_rsa + ssh-add ~/.ssh/id_materna +fi diff --git a/dot_bashrc.d/executable_08.alias b/dot_bashrc.d/executable_08.alias index b52d18b..bd41652 100644 --- a/dot_bashrc.d/executable_08.alias +++ b/dot_bashrc.d/executable_08.alias @@ -28,3 +28,8 @@ alias tailer="tail --follow=name --retry" # git aliases alias gg='git graph' + +# aliases to own scripts +alias start-agent='start-agent.sh' +alias find-agent='find-agent.sh' +alias findAgent='find-agent.sh'