-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bash_profile
27 lines (24 loc) · 1020 Bytes
/
.bash_profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
#
# setup ssh-agent
#
export PATH=~/.gems/bin:$PATH
# set environment variables if user's agent already exists
[ -z "$SSH_AUTH_SOCK" ] && SSH_AUTH_SOCK=$(ls -l /tmp/ssh-*/agent.* 2> /dev/null | grep $(whoami) | awk '{print $9}')
[ -z "$SSH_AGENT_PID" -a -z `echo $SSH_AUTH_SOCK | cut -d. -f2` ] && SSH_AGENT_PID=$((`echo $SSH_AUTH_SOCK | cut -d. -f2` + 1))
[ -n "$SSH_AUTH_SOCK" ] && export SSH_AUTH_SOCK
[ -n "$SSH_AGENT_PID" ] && export SSH_AGENT_PID
# start agent if necessary
if [ -z $SSH_AGENT_PID ] && [ -z $SSH_TTY ]; then # if no agent & not in ssh
eval `ssh-agent -s` > /dev/null
fi
# setup addition of keys when needed
if [ -z "$SSH_TTY" ] ; then # if not using ssh
ssh-add -l > /dev/null # check for keys
if [ $? -ne 0 ] ; then
alias ssh='ssh-add -l > /dev/null || ssh-add && unalias ssh ; ssh'
if [ -f "/usr/lib/ssh/x11-ssh-askpass" ] ; then
SSH_ASKPASS="/usr/lib/ssh/x11-ssh-askpass" ; export SSH_ASKPASS
fi
fi
fi