Use multiple 1Password accounts with 1Password CLI
When you use the 1Password desktop app integration to sign in to 1Password CLI, you can access any 1Password account you've added to the app on the command line.
By default, all 1Password CLI commands are executed with the account you most recently signed in to, unless an account is specified with the --account
flag.
Choose an account to sign in to with op signin
To choose an account to sign in to, run op signin
and select the account you want to sign in to from the list of accounts added to your 1Password app.
See result...
If you don't see the account you want to use, you may need to add it to the 1Password app.
Specify an account per command with the --account
flag
You can execute a command with a specific account by including the --account
flag along with the account's sign-in address (with or without https://) or ID.
For example, to get a list of all vaults in an account with the sign-in address my.1password.com
:
You can use the --account
flag to specify different accounts in scripts. For example:
Set an account with the OP_ACCOUNT
environment variable
If you only want to sign in to a specific account, set the OP_ACCOUNT
environment variable to the account's sign-in address or ID. You can also use this to specify an account in scripts.
- Bash, Zsh, sh
- fish
- PowerShell
Find an account sign-in address or ID
To find details about all the accounts you've added to the 1Password app, run op account list
.
See result...
You can use the sign-in address listed under URL
or the unique identifier listed under USER ID
to refer to the account.