Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

m1yam0t0/op-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

op-tool

op-tool makes it convenient to use 1Password command-line tool.

  • Copy credential to clipboard
  • Support fzf
    • Select item
    • Select field ("Password", "One-Time Password" and so on.)
  • Restore 1Password CLI session
    • If session is expired, op-tool recreate session and restore it.

Requirement

op-tool require these tools.

Using Homebrew

brew cask install 1password-cli
brew install jq fzf

Installation

To install op-tool, please use below methods.

Using Zinit

zinit ice pick"bin/op-tool" as"program"
zinit light m1yam0t0/op-tool

Install Manually

Clone this repository.

git clone https://github.com/m1yam0t0/op-tool.git

Set PATH to repo

export PATH="${PATH}:/path/to/op-tool/bin"

Usage

main command

❯ op-tool -h
op-tool - make it convenient to use 1Password CLI

Usage:
    op-tool <command> [<args>]
    op-tool -h | --help
    op-tool -v | --version

Commands:
    get                 Get password from 1Password Vault
    session             Restore op session

Options:
    -h, --help          Show this message
    -v, --version       Print the op-tool version

op-tool get

op-tool get - Get credential from 1Password

Usage:
    op-tool get [(-n|--name) <name>] [(-f|--field) <field>] [(-i|--interactive)] [--otp]
    op-tool get -h | --help
    op-tool get -v | --version

Options:
    -n, --name          1Password item name
    -f, --field         1Password item fields
    -i, --interactive   Select field interactive
    --otp               Get One-time Password
    -h, --help          Show this message
    -v, --version       Print the op-tool version

op-tool provides an interactive interface with a fuzzy-finder(fzf).

  • select item

select_item_fzf

  • select field

select_field_fzf

Copy credential from 1password.

~
❯ op-tool get
You have already logged in.
Copied 1Password item to clipboard. (item=Google, field=password)

Get specific item

❯ op-tool get -n "Google"
You have already logged in.
Copied 1Password item to clipboard. (item=Google, field=password)

Get optional field (default=password).

❯ op-tool get -n "Google" -f "username"
You have already logged in.
Copied 1Password item to clipboard. (item=Google, field=username)

Copy One-Time password

❯ op-tool get -n "Google" --otp
You have already logged in.
Copied 1Password item to clipboard. (item=Google, field=One-time Password)

op-tool session

Restore 1Password CLI session to ${XDG_CONFIG_CACHE}/op/session

❯ op-tool session
[ERROR] 2020/08/08 18:10:03 You are not currently signed in. Please run `op signin --help` for instructions
Enter the password for <email_address> at my.1password.com:
op session restored.
❯ cat ~/.cache/op/session
export OP_SESSION_my="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# This command is meant to be used with your shell's eval function.
# Run 'eval $(op signin my)' to sign in to your 1Password account.
# Use the --raw flag to only output the session token.