File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash -e
2
+
3
+ if [ " $( uname) " = " Linux" ]; then
4
+ # https://docs.github.com/en/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases#auto-launching-ssh-agent-on-git-for-windows
5
+ env=~ /.ssh/agent.env
6
+
7
+ agent_load_env () {
8
+ test -f " $env " && . " $env " > | /dev/null ;
9
+ }
10
+
11
+ agent_start () {
12
+ (umask 077; ssh-agent > | " $env " )
13
+ . " $env " > | /dev/null ;
14
+ }
15
+
16
+ agent_load_env
17
+
18
+ # agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2=agent not running
19
+ agent_run_state=$( ssh-add -l > | /dev/null 2>&1 ; echo $? )
20
+
21
+ if [ ! " $SSH_AUTH_SOCK " ] || [ $agent_run_state = 2 ]; then
22
+ echo Adding ssh identity
23
+ agent_start
24
+ ssh-add ~ /.ssh/id_ed25519
25
+ elif [ " $SSH_AUTH_SOCK " ] && [ $agent_run_state = 1 ]; then
26
+ echo Adding ssh identity
27
+ ssh-add ~ /.ssh/id_ed25519
28
+ fi
29
+
30
+ unset env
31
+ fi
You can’t perform that action at this time.
0 commit comments