Skip to content
command line tool for using op (https://support.1password.com/command-line/) like as key-value
Go Makefile
Branch: master
Clone or download
skutsuza
skutsuza fix
Latest commit 1f2535d Sep 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Refactor (#9) Sep 27, 2019
cmd/op-kv Refactor (#9) Sep 27, 2019
pkg Username (#12) Sep 28, 2019
testdata Username (#12) Sep 28, 2019
.gitignore add release job (#4) Mar 21, 2019
.goreleaser.yml remove go generate step in gorelaser Sep 24, 2019
LICENSE Create LICENSE (#7) Sep 24, 2019
Makefile add Makefile Feb 16, 2019
README.md fix Sep 28, 2019
codecov.yml up testcoverage Sep 27, 2019
go.mod Refactor (#9) Sep 27, 2019
go.sum Refactor (#9) Sep 27, 2019

README.md

op-kv

Actions Status Go Report Card License: MIT

This CLI can use op (https://support.1password.com/command-line/) like as key-value.

Install

go

$ go get github.com/cappyzawa/op-kv/cmd/op-kv

zdharma/zplugin

zplugin ice wait'2' lucid as"program" from"gh-r" \
  has"op"
zplugin light cappyzawa/op-kv

Required

Usage

This cli required $XDG_CONFIG_HOME/.op/config (or $HOME/.op/config) file. This file is created by executing op signin.

$ op signin -h
usage: op signin <signinaddress> <emailaddress>

Example account details:

   <signinaddress>   example.1password.com
   <emailaddress>    user@example.com

If you set OP_PASSWORD as master password to ENV var, op-kv command is very easy.

$ 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

$ op-kv write -h 
Generate one password by specified item and password

Usage:
  op-kv write <key> <value> [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 ()
$ op-kv write -p testPassword testItem
success to write password (testPassword) and username () to "testItem"

This Command is same as below.

$ 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

$ op-kv read -h
Display one password of specified item by UUID or name

Usage:
  op-kv read <key> [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
$ op-kv read testItem
testPassword

This Command is same as below.

$ 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.

$ 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

$ op-kv list -h
Display item titles

Usage:
  op-kv list [flags]

Flags:
  -h, --help   help for list

This Command is same as below.

$ op list items | jq -r ".[].overview.title"
You can’t perform that action at this time.