From e09c21501c20730634ab80d6bc9329335eabe065 Mon Sep 17 00:00:00 2001 From: kyb Date: Fri, 3 Aug 2018 08:25:45 +0300 Subject: [PATCH] All in one file. --- functions/__ssh_agent_is_started.fish | 13 ------------- functions/__ssh_agent_start.fish | 6 ------ functions/fish_ssh_agent.fish | 25 ++++++++++++++++++++++++- 3 files changed, 24 insertions(+), 20 deletions(-) delete mode 100644 functions/__ssh_agent_is_started.fish delete mode 100644 functions/__ssh_agent_start.fish diff --git a/functions/__ssh_agent_is_started.fish b/functions/__ssh_agent_is_started.fish deleted file mode 100644 index fb3b46e..0000000 --- a/functions/__ssh_agent_is_started.fish +++ /dev/null @@ -1,13 +0,0 @@ -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 -q ssh-agent - #pgrep ssh-agent - return $status -end diff --git a/functions/__ssh_agent_start.fish b/functions/__ssh_agent_start.fish deleted file mode 100644 index 8bd260b..0000000 --- a/functions/__ssh_agent_start.fish +++ /dev/null @@ -1,6 +0,0 @@ -function __ssh_agent_start -d "start a new ssh agent" - ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV - chmod 600 $SSH_ENV - source $SSH_ENV > /dev/null - true # suppress errors from setenv, i.e. set -gx -end diff --git a/functions/fish_ssh_agent.fish b/functions/fish_ssh_agent.fish index 0c74c29..5960b75 100644 --- a/functions/fish_ssh_agent.fish +++ b/functions/fish_ssh_agent.fish @@ -1,3 +1,26 @@ +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 -q ssh-agent + #pgrep ssh-agent + return $status +end + + +function __ssh_agent_start -d "start a new ssh agent" + ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV + chmod 600 $SSH_ENV + source $SSH_ENV > /dev/null + true # suppress errors from setenv, i.e. set -gx +end + + function fish_ssh_agent --description "Start ssh-agent if not started yet, or uses already started ssh-agent." if test -z "$SSH_ENV" set -xg SSH_ENV $HOME/.ssh/environment @@ -6,4 +29,4 @@ function fish_ssh_agent --description "Start ssh-agent if not started yet, or us if not __ssh_agent_is_started __ssh_agent_start end -end \ No newline at end of file +end