Forum Discussion

flozza's avatar
flozza
New Contributor
9 months ago

Search for CLI

Hi!

I'd like to request a feature: For the 1Password CLI (`op`) to support searching, just like the GUI client does.

My use case: I have about 30 or so entries that I would like to add a tag to. All entries belong to the same domain "home.mydomain.com" (many have subdomains on it). In the GUI client I type "home.mydomain.com" and they all come up.

I want to use a script using the `op` CLI to edit each, adding a tag to them. Right now the only method I can find is to first list all items and then retrieve each and do the search myself. That's very slow. It would be great if I could send a search them off and get back a list of results.

This could be as simple as `op item search "home.mydomain.com" --format=json` and then I could edit each of those items.

Thanks!

5 Replies

  • mcky's avatar
    mcky
    New Contributor

    Too late for the op but maybe this is useful for someone else

    If you have fzf installed, this one liner will search and then print the content

    op item get (op item list | fzf --header-lines=1 | awk '{print $1}')

     

    • thecatfix's avatar
      thecatfix
      Dedicated Contributor
      op item get $(op item list | fzf --header-lines=1 | awk '{print $1}')

      This is AWESOME 

      • thecatfix's avatar
        thecatfix
        Dedicated Contributor
        op item get $(op item list --format json | jq -r '.[] | "\(.id) \(.title) [\(.vault.name)]"' | fzf | awk '{print $1}')

        For a cleaner selection interface that includes the Vault name and avoids parsing whitespace columns, use jq to format the entry before passing it to fzf.

  • 1P_SimonH's avatar
    1P_SimonH
    Icon for Community Manager rankCommunity Manager

    jake thanks for sharing a potential workaround!

    flozza I've also added your suggestion as a feature request for consideration. Thanks for so clearly laying out your use case!

    ref: PB-49237143

  • jake's avatar
    jake
    New Contributor

    Although it may not exist in OP - have you considered using the API service? You can throw together a simple api handler in Python.

    GET /v1/vaults/{vault_id}/items?filter=title contains "bank"

    GET /v1/vaults/{vault_id}/items?filter=title eq "Amazon" and category eq "LOGIN"