About 1Password CLI 2
We released version 2 of the 1Password CLI in March 2022. Since then, more than 96% of users have adopted the latest version. 1Password CLI 2 includes a number of changes to the schema to make the tool easier to use as well as new features to help you provision secrets.New schema
1Password CLI 2 introduces a noun-verb command structure that groups commands by topic rather than by operation. You can find all available topics withop --help, and see the commands avaialble for each topic with op <topic> --help. Topics include:
Other schema changes include:
- The default output is now a human-friendly, tabular schema.
- The JSON output schema now contains more useful information.
- Improved stdin processing allows you to chain more commands together.
- The new schema uses flags instead of positional arguments.
Secrets provisioning
To help you provision secrets locally, 1Password CLI 2 allows you to load secrets directly from 1Password in environment variables and configuration files. With secrets provisioning, you can replace your plaintext secrets with references to the secrets stored in 1Password and load them at runtime in your scripts, applications, and other workflows.Integrate 1Password CLI with the 1Password desktop app
You can sign in to 1Password CLI 2 with the accounts you’ve added to the 1Password desktop app, then authenticate your accounts on the command line with biometrics.Shell plugins
To simplify and secure your workflow, 1Password CLI 2 introduces shell plugins that allow you to securely authenticate third-party command-line tools using biometrics.Package manager installation
1Password CLI 2 supports easier installation with package managers including Apt, Yum, Alpine, and tar. You can find all changes in the changelog. To share feedback with us, visit the support community forum.Step 1: Choose an upgrade strategy
There are multiple ways to upgrade to 1Password CLI 2. You can upgrade immediately or gradually, depending on your workflow and toolchain.Upgrade immediately
The quickest way to upgrade to 1Password CLI 2 is to overwrite your existing installation. This is a good option if you have a small team who can upgrade their local installations simultaneously.-
Use
which op(or(Get-Command op).Pathon Windows) to get the directory of the current installation. -
Download 1Password CLI 2 and move
opto the same directory, overwriting the existing copy. -
To verify the installation, check the version number:
- Update your scripts to use the 1Password CLI 2 syntax.
Upgrade gradually
If you’re not ready to upgrade immediately, you can use Docker to upgrade individual projects or use both versions of 1Password CLI side-by-side. We will continue to support version 1 for one year after version 2 is released.Use Docker to upgrade individual projects
If you want to upgrade project by project, you can Dockerize your workflow so that each team member uses the version of 1Password CLI in a Docker image for a specific project. This is a good option for large teams, because it doesn’t require each team member to update a local installation.-
Use the 1Password CLI Docker image or use your own image and add the CLI. Your Dockerfile should look like this:
- After upgrading to 1Password CLI 2, update your scripts to use the new command syntax.
This approach also sets you up to move your scripts to headless environments such as CI/CD pipelines.
Use both versions of 1Password CLI
If your scripts depend on the local installation on each team member’s machine, and you still want to migrate gradually, this is your best option. Each team member should do the following:- Rename the earlier version of 1Password CLI
op1. - Find and replace all occurences of
opwithop1. - Install 1Password CLI 2 inside your
$PATH.
- Update your scripts one-by-one to use the new
op. You can continue to use your current scripts with the earlier version of 1Password CLI installed asop1. - When you’ve updated all your scripts and are ready to upgrade, uninstall the earlier version of 1Password CLI.
- Find and replace all occurrences of
op1in your scripts toop.
Step 2: Update your scripts
If you’ve been using an earlier version of 1Password CLI in scripts, you’ll need to update your scripts to the new syntax. After you install 1Password CLI 2, use the following table to update your scripts. It shows all the updated commands and associated changes to arguments or flags.Appendix: Change default output to JSON
The default output format for 1Password CLI 2 is a human-readable, tabular schema. You can change the default to machine-readable JSON in two ways:- For a single command, include the
--format jsonflag with your command. For example,op item get <name> --format json. - To always default to JSON, set the
$OP_FORMATenvironment variable tojson.
Appendix: Item JSON template
You can expect to see several formatting improvements and field name changes in 1Password CLI 2 item JSON templates.Old template
New template
Section
Field
Get help
If you need help upgrading to 1Password CLI 2, contact 1Password Support or join our Developer Slack workspace and ask a question in the#cli channel.