[zsh] Embed connect_ssh_agent in a function
This commit is contained in:
		
							parent
							
								
									fd56b6b7b6
								
							
						
					
					
						commit
						4b566050af
					
				
					 1 changed files with 13 additions and 8 deletions
				
			
		|  | @ -1,12 +1,17 @@ | |||
| #!/usr/bin/env zsh | ||||
| # Eryn Wells <eryn@erynwells.me> | ||||
| 
 | ||||
| # Start SSH agent for password-less logins | ||||
| if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then | ||||
|     if ! pgrep -u $USER ssh-agent 1>/dev/null; then | ||||
|         eval $(ssh-agent -s > ~/.ssh_agent_vars) | ||||
|         trap "kill $SSH_AGENT_PID" 0 | ||||
|     else | ||||
|         eval $(cat ~/.ssh_agent_vars) | ||||
| function connect_ssh_agent | ||||
| { | ||||
|     # Start SSH agent for password-less logins | ||||
|     if [[ -z "$SSH_AUTH_SOCK" && -x "$SSHAGENT" ]]; then | ||||
|         if ! pgrep -u $USER ssh-agent 1>/dev/null; then | ||||
|             eval $(ssh-agent -s > ~/.ssh_agent_vars) | ||||
|             trap "kill $SSH_AGENT_PID" 0 | ||||
|         else | ||||
|             eval $(cat ~/.ssh_agent_vars) | ||||
|         fi | ||||
|     fi | ||||
| fi | ||||
| } | ||||
| 
 | ||||
| connect_ssh_agent "$@" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue