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: 7 days 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 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-06T20:37:58.000Z (about 5 years ago)
- Last Synced: 2026-01-15T04:29:12.650Z (5 months ago)
- Topics: 1password-cli, cli, go
- Language: Go
- Homepage:
- Size: 72.3 KB
- Stars: 2
- Watchers: 0
- 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 signin
Example account details:
example.1password.com
user@example.com
```
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 kv
Usage:
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 password
Flags:
-h, --help help for op-kv
--op-password string password for 1password
-d, --subdomain string subdomain of 1password
Use "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 password
Usage:
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 name
Usage:
op-kv read [flags]
Flags:
-h, --help help for read
--table Print username and password of the item as Table
Global 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 titles
Usage:
op-kv list [flags]
Flags:
-h, --help help for list
```
This Command is same as below.
```bash
$ op list items | jq -r ".[].overview.title"
```