cmder/vendor/user_profile.sh.default
2018-12-13 12:13:17 -08:00

32 lines
875 B
Plaintext

# use this file to run your own startup commands for msys2 bash'
# To add a new vendor to the path, do something like:
# export PATH=${CMDER_ROOT}/vendor/whatever:${PATH}
function launch_ssh_agent {
# Copied from (https://help.github.com/articles/working-with-ssh-key-passphrases)
env=~/.ssh/agent.env
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }
agent_load_env
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
agent_start
ssh-add
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
ssh-add
fi
unset env
}
# Run ssh-agent automatically when you open your first bash terminal
# launch_ssh_agent