Category
Tags

Using pinentry-mac to sign commits from vim-fugitive

In order to sign git commits from within Vim using a plugin like tpope/vim-fugitive, it is necessary to configure the gpg-agent to use a GUI based pinentry-program.

Preface

The man, the myth, the legend, Timothy Popallopollis himself recommends configuring your gpg-agent to use a GUI based pinentry-program. On macOS this can be done quite by simply installing pinentry-mac, and updating your gpg-agent.conf.

Configuration

First things first, let's install the pinentry program.

$ brew install pinentry-mac

Then, all we need to do is set the pinentry-program option in your ~/.gnupg/gpg-agent.conf file.

default-cache-ttl 600
max-cache-ttl 7200
pinentry-program /opt/homebrew/bin/pinentry-mac

If your don't know the path to your pinentry program, you can throw down a quick which.

$ which pinentry-mac
/opt/homebrew/bin/pinentry-mac

Or use your Homebrew prefix.

$ echo $(brew --prefix)/bin/pinentry-mac
/opt/homebrew/bin/pinentry-mac

But that's all it takes. Now, you should be prompted to enter your gpg pin in an external window when signing commits from vim.