Skip to content

Instantly share code, notes, and snippets.

@massahud
Last active November 13, 2025 16:39
Show Gist options
  • Select an option

  • Save massahud/d3d429a91436a42055ca7d62f5938265 to your computer and use it in GitHub Desktop.

Select an option

Save massahud/d3d429a91436a42055ca7d62f5938265 to your computer and use it in GitHub Desktop.
GnuPG curses prompt

GnuPG curses prompt

Install pinentry-curses.

brew install pinentry-curses

Configure the agent to use pinentry-curses

echo 'export GPG_TTY=$(tty)' >> ~/.zshrc
echo 'pinentry-program /opt/homebrew/bin/pinentry-curses' > ~/.gnupg/gpg-agent.conf
echo 'allow-loopback-pinentry' >> ~/.gnupg/gpg-agent.conf
killall gpg-agent
source ~/.zshrc
echo test | gpg --clearsign

If using powerlevel10k, add this to ~/.zshrc after the call to source .p10k.sh

# powerlevel10k with instant prompt does not support tty while initilizing
if [ $ZSH_THEME="powerlevel10k/powerlevel10k" ]; then
	export GPG_TTY=$TTY
fi

Making it use keychain on Cursor/VsCode:

Install pinentry-mac.

brew install pinentry-mac
  1. Create ~/bin/pinentry-selector.sh script
#!/bin/zsh
#
# Needs to have pinentry-mac and pinentry-curses installed with homebrew
#

if [ -n "$VSCODE_PID" ]; then
    # if vscode, use pinentry-mac (keychain)
    exec /opt/homebrew/bin/pinentry-mac "$@"
else
    # by default use the console pinentry
    exec /opt/homebrew/bin/pinentry-curses "$@"
fi
  1. Create/edit ~/.gnupg/gpg-agent.conf
pinentry-program ~/bin/pinentry-selector
allow-loopback-pinentry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment