1password support for xonsh
If you like the idea click ⭐ on the repo and tweet.
ALPHA: This is the initial release. Issues/pull requests are welcome.
This xontrib adds support for 1Password secrets to the xonsh shell by utilizing the [op (1password CLI)][https://developer.1password.com/docs/cli/]. It works by allowing you to securely store and access your passwords in 1Password. To use:
- Store your passwords in 1Password.
- In your xonsh environment, reference the passwords using the OnePass function:
$OPENAI_API_KEY = OnePass("op://Private/OpenAI-API-Key/api-key")
- To expose the variables in your environment, set:
$ONEPASS_ENABLED = 1
This approach ensures your sensitive information remains secure while being easily accessible in your xonsh shell. The URL is basically: op://<Vault>/<title>/<field>
. To find this, here's the commands I used to determine these fields:
➜ xonsh op item list --format json | jq '.[].title | select(. | contains("OpenAI"))'
"OpenAI-API-Key"
➜ xonsh op item get OpenAI-API-Key --format json | jq '.fields[] | select(.type == "CONCEALED") | .label'
"api-key"
To install use pip:
xpip install xontrib-1password
# or: xpip install -U git+https://github.com/drmikecrowe/xontrib-1password
This xontrib will get loaded automatically for interactive sessions. To stop this, set
$XONTRIBS_AUTOLOAD_DISABLED = ["1password", ]
# if you have set this for other xontribs, you should append the vale
None
- activate pre-commit hooks
# install pre-commit plugins and activate the commit hook
pre-commit install
pre-commit autoupdate
- Bump the version of your package.
- Create a GitHub release (The release notes are automatically generated as a draft release after each push).
- And publish with
poetry publish --build
ortwine
This package was created with xontrib template.