Created
          September 15, 2015 13:44 
        
      - 
      
- 
        Save alexeiz/984289f5184f27388a15 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # source into bashrc, zshrc | |
| # ssh-agent management functions for cygwin/msys2 | |
| export _SSH_AGENT_LOCK=/tmp/ssh-agent.lock | |
| start_ssh_agent() { | |
| if [ -e $_SSH_AGENT_LOCK ]; then | |
| use_ssh_agent | |
| else | |
| eval `ssh-agent` | |
| echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $_SSH_AGENT_LOCK | |
| echo "export SSH_AGENT_PID=$SSH_AGENT_PID" >> $_SSH_AGENT_LOCK | |
| ssh-add | |
| fi | |
| } | |
| stop_ssh_agent() { | |
| if [ -e $_SSH_AGENT_LOCK ]; then | |
| source $_SSH_AGENT_LOCK | |
| rm -f $_SSH_AGENT_LOCK | |
| ssh-agent -k | |
| fi | |
| } | |
| use_ssh_agent() { | |
| if [ -e $_SSH_AGENT_LOCK ]; then | |
| source $_SSH_AGENT_LOCK | |
| else | |
| echo "ssh-agent not found" | |
| fi | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment