Created
June 29, 2017 02:12
-
-
Save dashawk/fbdb9402c4d37bc7285782ac83dca017 to your computer and use it in GitHub Desktop.
My Windows .bashrc
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
#!/bin/bash | |
# Make .bashrc available to non interactive shells (.sh scripts) | |
export BASH_ENV=~/.bashrc | |
env=~/.ssh/agent.env | |
loadEnv () { | |
test -f "$env" && . "$env" >| /dev/null ; | |
} | |
startAgent() { | |
(umask 077; ssh-agent >| "$env") | |
. "$env" >| /dev/null ; | |
} | |
addKeys() { | |
keys=`find ~/.ssh -name '*_rsa'` | |
if [ "$keys" ]; then | |
for i in $keys; do | |
local identity=`ssh-keygen -lf $i` | |
ssh-add -l | grep -q "$identity" || ssh-add $i | |
done | |
fi | |
} | |
loadEnv | |
sshState=$(ssh-add -l >| /dev/null 2>&1; echo $?) | |
if [ ! "$SSH_AUTH_SOCK" ] || [ $sshState = 2 ]; then | |
startAgent | |
addKeys | |
elif [ "$SSH_AUTH_SOCK" ] && [ $sshState = 1 ]; then | |
addKeys | |
fi | |
unset env |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment