Add ssh-agent setup for fish
This commit is contained in:
parent
0b6f2f8b00
commit
6781da5828
3 changed files with 39 additions and 0 deletions
|
@ -42,6 +42,26 @@ alias mkdir "mkdir -p"
|
||||||
# Make sl run ls afterwards
|
# Make sl run ls afterwards
|
||||||
alias sl "/usr/local/bin/sl; and ls"
|
alias sl "/usr/local/bin/sl; and ls"
|
||||||
|
|
||||||
|
# SSH Agent
|
||||||
|
setenv SSH_ENV "$HOME/.ssh/environment"
|
||||||
|
if [ -n "$SSH_AGENT_PID" ]
|
||||||
|
ps -ef | grep $SSH_AGENT_PID | grep ssh-agent > /dev/null
|
||||||
|
if [ $status -eq 0 ]
|
||||||
|
test_identities
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if [ -f $SSH_ENV ]
|
||||||
|
. $SSH_ENV > /dev/null
|
||||||
|
end
|
||||||
|
ps -ef | grep $SSH_AGENT_PID | grep -v grep | grep ssh-agent > /dev/null
|
||||||
|
if [ $status -eq 0 ]
|
||||||
|
test_identities
|
||||||
|
else
|
||||||
|
start_agent
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Fish colour customisations
|
# Fish colour customisations
|
||||||
set fish_color_autosuggestion "-o" "black"
|
set fish_color_autosuggestion "-o" "black"
|
||||||
set fish_color_command "-o" "cyan"
|
set fish_color_command "-o" "cyan"
|
||||||
|
|
9
fish/functions/start_agent.fish
Normal file
9
fish/functions/start_agent.fish
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
function start_agent
|
||||||
|
echo "Initializing new SSH agent ..."
|
||||||
|
ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV
|
||||||
|
echo "succeeded"
|
||||||
|
chmod 600 $SSH_ENV
|
||||||
|
. $SSH_ENV > /dev/null
|
||||||
|
ssh-add
|
||||||
|
end
|
||||||
|
|
10
fish/functions/test_identities.fish
Normal file
10
fish/functions/test_identities.fish
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
function test_identities
|
||||||
|
ssh-add -l | grep "The agent has no identities" > /dev/null
|
||||||
|
if [ $status -eq 0 ]
|
||||||
|
ssh-add
|
||||||
|
if [ $status -eq 2 ]
|
||||||
|
start_agent
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue