summaryrefslogtreecommitdiffstats
path: root/.config/fish/functions
diff options
context:
space:
mode:
authorYigit Sever2024-04-25 17:45:48 +0300
committerYigit Sever2024-04-25 17:45:48 +0300
commit7bc07e5f4696da9f7881625d2fbe3d1cde86539b (patch)
treeea2b5246d8ed743af255011017ccaf0194b099af /.config/fish/functions
parentdb36e3c3957f01de9128971f326d36d4dc1d81bd (diff)
downloaddotfiles-7bc07e5f4696da9f7881625d2fbe3d1cde86539b.tar.gz
dotfiles-7bc07e5f4696da9f7881625d2fbe3d1cde86539b.tar.bz2
dotfiles-7bc07e5f4696da9f7881625d2fbe3d1cde86539b.zip
fish: use fish_ssh_agent
Diffstat (limited to '.config/fish/functions')
-rw-r--r--.config/fish/functions/fish_ssh_agent.fish32
1 files changed, 32 insertions, 0 deletions
diff --git a/.config/fish/functions/fish_ssh_agent.fish b/.config/fish/functions/fish_ssh_agent.fish
new file mode 100644
index 0000000..5960b75
--- /dev/null
+++ b/.config/fish/functions/fish_ssh_agent.fish
@@ -0,0 +1,32 @@
1function __ssh_agent_is_started -d "check if ssh agent is already started"
2 if begin; test -f $SSH_ENV; and test -z "$SSH_AGENT_PID"; end
3 source $SSH_ENV > /dev/null
4 end
5
6 if test -z "$SSH_AGENT_PID"
7 return 1
8 end
9
10 ps -ef | grep $SSH_AGENT_PID | grep -v grep | grep -q ssh-agent
11 #pgrep ssh-agent
12 return $status
13end
14
15
16function __ssh_agent_start -d "start a new ssh agent"
17 ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV
18 chmod 600 $SSH_ENV
19 source $SSH_ENV > /dev/null
20 true # suppress errors from setenv, i.e. set -gx
21end
22
23
24function fish_ssh_agent --description "Start ssh-agent if not started yet, or uses already started ssh-agent."
25 if test -z "$SSH_ENV"
26 set -xg SSH_ENV $HOME/.ssh/environment
27 end
28
29 if not __ssh_agent_is_started
30 __ssh_agent_start
31 end
32end