https://github.com/cappyzawa/op-kv
A command-line tool for using op (https://support.1password.com/command-line/) like as key-value
https://github.com/cappyzawa/op-kv
1password-cli cli go
Last synced: 3 months ago
JSON representation
A command-line tool for using op (https://support.1password.com/command-line/) like as key-value
- Host: GitHub
- URL: https://github.com/cappyzawa/op-kv
- Owner: cappyzawa
- License: mit
- Created: 2019-02-13T13:43:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-06T20:37:58.000Z (about 4 years ago)
- Last Synced: 2025-01-05T11:28:09.687Z (4 months ago)
- Topics: 1password-cli, cli, go
- Language: Go
- Homepage:
- Size: 72.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# op-kv
[](https://github.com/cappyzawa/op-kv/actions)
[](https://goreportcard.com/report/github.com/cappyzawa/op-kv)
[](https://opensource.org/licenses/MIT)This CLI can use op (https://support.1password.com/command-line/) like as key-value.
## Install
go
```bash
$ go get github.com/cappyzawa/op-kv/cmd/op-kv
```[zdharma/zplugin](https://github.com/zdharma/zplugin)
```zsh
zplugin ice wait'2' lucid as"program" from"gh-r" \
has"op"
zplugin light cappyzawa/op-kv
```## Required
* `op`: [1Password command\-line tool: Full documentation](https://support.1password.com/command-line/)## Usage
This cli required `$XDG_CONFIG_HOME/.op/config` (or `$HOME/.op/config`) file. This file is created by executing [`op signin`](https://support.1password.com/command-line/#sign-in-or-out).
```bash
$ op signin -h
usage: op signinExample account details:
example.1password.com
[email protected]
```If you set `OP_PASSWORD` as master password to ENV var, `op-kv` command is very easy.
```bash
$ op-kv -h
use "op" like as kvUsage:
op-kv [flags]
op-kv [command]Available Commands:
help Help about any command
list Display item titles
read Display one password of specified item by UUID or name
write Generate one password by specified item and passwordFlags:
-h, --help help for op-kv
--op-password string password for 1password
-d, --subdomain string subdomain of 1passwordUse "op-kv [command] --help" for more information about a command.
```if `-p` is not set, `$OP_PASSWORD` is used as password.
And if `-d` is not set, this cli access to latest signin subdomain.
### write
```bash
$ op-kv write -h
Generate one password by specified item and passwordUsage:
op-kv write [flags]Flags:
-h, --help help for write
-p, --password string register password to item(key)
-u, --username string register username to item(key)Global Flags:
--op-password string password for 1password ()
-d, --subdomain string subdomain of 1password ()
``````bash
$ op-kv write -p testPassword testItem
success to write password (testPassword) and username () to "testItem"
```This Command is same as below.
```bash
$ D=$(op get template login | jq -c '.fields[1].value = testPassword' | op encode)
$ op create item login $D --title=testItem
```This can adjust only _login_ template.
### Read
```bash
$ op-kv read -h
Display one password of specified item by UUID or nameUsage:
op-kv read [flags]Flags:
-h, --help help for read
--table Print username and password of the item as TableGlobal Flags:
--op-password string password for 1password
-d, --subdomain string subdomain of 1password
``````bash
$ op-kv read testItem
testPassword
```This Command is same as below.
```bash
$ op get item testItem | jq -r '.details.fields[] | select(.designation=="password").value'
```
This can adjust only _item_ subcommand.If you want to display username & password, you can use table flag.
```bash
$ op-kv write testTable -u testUsername -p testPassword
success to write password (testPassword) and username (testUsername) to "testTable"$ op-kv read testTable --table
| USERNAME | PASSWORD |
-----------------------------------------------------------------------------------------------
| testUsername | testPassword |```
### list
```bash
$ op-kv list -h
Display item titlesUsage:
op-kv list [flags]Flags:
-h, --help help for list
```This Command is same as below.
```bash
$ op list items | jq -r ".[].overview.title"
```