mirror of
https://github.com/danhper/fish-ssh-agent.git
synced 2025-09-27 22:25:27 +00:00
Move ssh_agent_is_started to its own function. Close #1.
This commit is contained in:
12
functions/__ssh_agent_is_started.fish
Normal file
12
functions/__ssh_agent_is_started.fish
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
function __ssh_agent_is_started -d "check if ssh agent is already started"
|
||||||
|
if begin; test -f $SSH_ENV; and test -z "$SSH_AGENT_PID"; end
|
||||||
|
source $SSH_ENV > /dev/null
|
||||||
|
end
|
||||||
|
|
||||||
|
if test -z "$SSH_AGENT_PID"
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
ps -ef | grep $SSH_AGENT_PID | grep -v grep | grep ssh-agent > /dev/null
|
||||||
|
return $status
|
||||||
|
end
|
@@ -1,4 +1,4 @@
|
|||||||
function __ssh_agent_start
|
function __ssh_agent_start -d "start a new ssh agent"
|
||||||
ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV
|
ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV
|
||||||
chmod 600 $SSH_ENV
|
chmod 600 $SSH_ENV
|
||||||
source $SSH_ENV > /dev/null
|
source $SSH_ENV > /dev/null
|
||||||
|
@@ -2,12 +2,6 @@ if test -z "$SSH_ENV"
|
|||||||
setenv SSH_ENV $HOME/.ssh/environment
|
setenv SSH_ENV $HOME/.ssh/environment
|
||||||
end
|
end
|
||||||
|
|
||||||
if test -z "$SSH_AGENT_PID"
|
if not __ssh_agent_is_started
|
||||||
if test -f $SSH_ENV
|
|
||||||
source $SSH_ENV > /dev/null
|
|
||||||
end
|
|
||||||
ps -ef | grep $SSH_AGENT_PID | grep -v grep | grep ssh-agent > /dev/null
|
|
||||||
if test $status -ne 0
|
|
||||||
__ssh_agent_start
|
__ssh_agent_start
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user