Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
e5b9b800
Unverified
Commit
e5b9b800
authored
Oct 05, 2021
by
Dapeng Gao
Committed by
GitHub
Oct 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(gpg-agent): correctly overwrite `$SSH_AUTH_SOCK` and other improvements (#7059)
parent
49bc55f9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
13 deletions
+14
-13
README.md
plugins/gpg-agent/README.md
+1
-1
gpg-agent.plugin.zsh
plugins/gpg-agent/gpg-agent.plugin.zsh
+13
-12
No files found.
plugins/gpg-agent/README.md
View file @
e5b9b800
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
Enables
[
GPG's gpg-agent
](
https://www.gnupg.org/documentation/manuals/gnupg/
)
if it is not running.
Enables
[
GPG's gpg-agent
](
https://www.gnupg.org/documentation/manuals/gnupg/
)
if it is not running.
To use it, add
gpg-agent
to the plugins array of your zshrc file:
To use it, add
`gpg-agent`
to the plugins array of your zshrc file:
```
zsh
```
zsh
plugins
=(
... gpg-agent
)
plugins
=(
... gpg-agent
)
...
...
plugins/gpg-agent/gpg-agent.plugin.zsh
View file @
e5b9b800
# Enable gpg-agent if it is not running-
# --use-standard-socket will work from version 2 upwards
AGENT_SOCK
=
$(
gpgconf
--list-dirs
|
grep
agent-socket |
cut
-d
:
-f
2
)
if
[[
!
-S
$AGENT_SOCK
]]
;
then
gpg-agent
--daemon
--use-standard-socket
&>/dev/null
fi
export
GPG_TTY
=
$TTY
export
GPG_TTY
=
$TTY
# Set SSH to use gpg-agent if it's enabled
# Fix for passphrase prompt on the correct tty
GNUPGCONFIG
=
"
${
GNUPGHOME
:-
"
$HOME
/.gnupg"
}
/gpg-agent.conf"
# See https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html#option-_002d_002denable_002dssh_002dsupport
if
[[
-r
$GNUPGCONFIG
]]
&&
command grep
-q
enable-ssh-support
"
$GNUPGCONFIG
"
;
then
function
_gpg-agent_update-tty_preexec
{
export
SSH_AUTH_SOCK
=
"
$AGENT_SOCK
.ssh"
gpg-connect-agent updatestartuptty /bye &>/dev/null
}
autoload
-U
add-zsh-hook
add-zsh-hook preexec _gpg-agent_update-tty_preexec
# If enable-ssh-support is set, fix ssh agent integration
if
[[
$(
gpgconf
--list-options
gpg-agent |
awk
-F
:
'$1=="enable-ssh-support" {print $10}'
)
=
1
]]
;
then
unset
SSH_AGENT_PID
unset
SSH_AGENT_PID
if
[[
"
${
gnupg_SSH_AUTH_SOCK_by
:-
0
}
"
-ne
$$
]]
;
then
export
SSH_AUTH_SOCK
=
"
$(
gpgconf
--list-dirs
agent-ssh-socket
)
"
fi
fi
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment