forked from sorin-ionescu/prezto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix sorin-ionescu#425] Rewrite module ssh-agent; rename it to ssh
- Loading branch information
1 parent
9732781
commit fcab2a1
Showing
5 changed files
with
79 additions
and
104 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
SSH | ||
=== | ||
|
||
Provides for an easier use of [SSH][1] by setting up [ssh-agent][2]. | ||
|
||
This module is disabled on Mac OS X due to custom Apple SSH support rendering it | ||
unnecessary. | ||
|
||
Settings | ||
-------- | ||
|
||
### Identities | ||
|
||
To load multiple identities, add the following line to *zpreztorc*: | ||
|
||
zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_dsa' 'id_github' | ||
|
||
Authors | ||
------- | ||
|
||
*The authors of this module should be contacted via the [issue tracker][3].* | ||
|
||
- [Sorin Ionescu](https://github.com/sorin-ionescu) | ||
|
||
[1]: http://www.openssh.com | ||
[2]: http://www.openbsd.org/cgi-bin/man.cgi?query=ssh-agent&sektion=1 | ||
[3]: https://github.com/sorin-ionescu/prezto/issues | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# | ||
# Provides for an easier use of SSH by setting up ssh-agent. | ||
# | ||
# Authors: | ||
# Sorin Ionescu <[email protected]> | ||
# | ||
|
||
# Return if requirements are not found. | ||
if [[ "$OSTYPE" == darwin* ]] || (( ! $+commands[ssh-agent] )); then | ||
return 1 | ||
fi | ||
|
||
# Set the path to the SSH directory. | ||
_ssh_dir="$HOME/.ssh" | ||
|
||
# Set the path to the environment file if not set by another module. | ||
_ssh_agent_env="${_ssh_agent_env:-$TMPDIR/ssh-agent.env}" | ||
|
||
# Set the path to the persistent authentication socket. | ||
_ssh_agent_sock="$TMPDIR/ssh-agent.sock" | ||
|
||
# Start ssh-agent if not started. | ||
if [[ ! -S "$SSH_AUTH_SOCK" ]]; then | ||
eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")" | ||
else | ||
# Export environment variables. | ||
source "$_ssh_agent_env" 2> /dev/null | ||
fi | ||
|
||
# Load identities. | ||
if ssh-add -l 2>&1 | grep 'The agent has no identities'; then | ||
zstyle -a ':prezto:module:ssh:load' identities '_ssh_identities' | ||
if (( ${#identities} > 0 )); then | ||
ssh-add "$_ssh_dir/${^_ssh_identities[@]}" | ||
else | ||
ssh-add | ||
fi | ||
fi | ||
|
||
# Create a persistent SSH authentication socket. | ||
if [[ -S "$SSH_AUTH_SOCK" && "$SSH_AUTH_SOCK" != "$_ssh_agent_sock" ]]; then | ||
ln -sf "$SSH_AUTH_SOCK" "$_ssh_agent_sock" | ||
export SSH_AUTH_SOCK="$_ssh_agent_sock" | ||
fi | ||
|
||
# Clean up. | ||
unset _ssh_{dir,identities} _ssh_agent_{env,sock} | ||
|
This file contains 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