commit 5aa699d4651c084640bc37f8f2931b33ff400213 Author: Daniel Perez Date: Wed Nov 4 21:34:14 2015 +0900 Initial commit. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5145f4d --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# fish-ssh-agent + +Utility functions to start your ssh agent when using fish shell. +You will only need to run `ssh-add` and type your password once, +after the running ssh_agent should do the work for you. + +## Installation + +### Using [fundle](https://github.com/tuvistavie/fundle) (recommended) + +Add + +``` +fundle plugin 'tuvistavie/fish-ssh-agent' +``` + +to your `config.fish`, reload your shell and run `fundle install`. + +### Manually + +Put `functions/__ssh_agent_start` your `~/.config/fish/functions` directory, +and source `init.fish` on startup. diff --git a/functions/__ssh_agent_start.fish b/functions/__ssh_agent_start.fish new file mode 100644 index 0000000..059e01f --- /dev/null +++ b/functions/__ssh_agent_start.fish @@ -0,0 +1,5 @@ +function __ssh_agent_start + ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV + chmod 600 $SSH_ENV + source $SSH_ENV > /dev/null +end diff --git a/init.fish b/init.fish new file mode 100644 index 0000000..2f2f4cb --- /dev/null +++ b/init.fish @@ -0,0 +1,13 @@ +if test -z "$SSH_ENV" + setenv SSH_ENV $HOME/.ssh/environment +end + +if test -z "$SSH_AGENT_PID" + 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 + end +end