-
-
Save nawan95/772746085df2ec073c20b242eb84a017 to your computer and use it in GitHub Desktop.
1Password CLI pinentry for gpg-agent
This file contains hidden or 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
| #!/bin/sh | |
| get_pin() { | |
| op read "$OP_PIN_ITEM" | |
| } | |
| echo "OK" | |
| while read -r cmd rest; do | |
| echo "cmd=$cmd rest=$rest" >&2 | |
| echo "cmd=$cmd rest=$rest" >> /tmp/logs | |
| case "$cmd" in | |
| \#*) | |
| echo "OK" | |
| ;; | |
| GETPIN) | |
| # Use modern $(...) syntax which is safer than backticks `` | |
| # This calls the function we defined above. | |
| PASSPHRASE=${PASSPHRASE-$(get_pin)} | |
| echo "D ${PASSPHRASE}" | |
| echo "OK" | |
| ;; | |
| BYE) | |
| echo "OK" | |
| exit 0 | |
| ;; | |
| *) | |
| echo "OK" | |
| ;; | |
| esac | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment