Last active
March 9, 2024 18:28
-
-
Save grische/852d856eb80e2992ba8400ebcf6f5488 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -z "$XDG_RUNTIME_DIR" ]; then | |
export XDG_RUNTIME_DIR=$HOME/.xdg | |
mkdir -m700 -p ${XDG_RUNTIME_DIR} | |
fi | |
# Check if we found an environment file already | |
if [[ ! "$SSH_AUTH_SOCK" ]]; then | |
if [ -e "$XDG_RUNTIME_DIR/ssh-agent.env" ]; then | |
source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null | |
# Check if current ssh-agent is still running | |
if ! kill -0 "$SSH_AGENT_PID" > /dev/null; then | |
ssh-agent -t 15h > "$XDG_RUNTIME_DIR/ssh-agent.env" | |
fi | |
else | |
ssh-agent -t 15h > "$XDG_RUNTIME_DIR/ssh-agent.env" | |
fi | |
source "$XDG_RUNTIME_DIR/ssh-agent.env" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment