> ## Documentation Index
> Fetch the complete documentation index at: https://www.1password.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Use multiple 1Password accounts with 1Password CLI

export const CodeResult = ({children, resultLang, wrap, expandable}) => {
  const parseChildren = () => {
    let language = "text";
    let codeContent = "";
    const extractText = node => {
      if (typeof node === "string") {
        return node;
      }
      if (Array.isArray(node)) {
        return node.map(extractText).join("");
      }
      if (node?.props?.children) {
        return extractText(node.props.children);
      }
      return "";
    };
    const extractLanguage = node => {
      if (!node) return null;
      if (node.props?.className) {
        const className = node.props.className;
        const langMatch = className.match(/language-(\w+)/);
        if (langMatch) {
          return langMatch[1];
        }
      }
      if (node.props?.["data-language"]) {
        return node.props["data-language"];
      }
      if (node.props?.language) {
        return node.props.language;
      }
      return null;
    };
    if (typeof children === "string") {
      codeContent = children;
    } else if (Array.isArray(children)) {
      codeContent = extractText(children);
      for (const child of children) {
        const detectedLang = extractLanguage(child);
        if (detectedLang) {
          language = detectedLang;
          break;
        }
      }
    } else if (children?.props) {
      const detectedLang = extractLanguage(children);
      if (detectedLang) {
        language = detectedLang;
      }
      codeContent = extractText(children);
    }
    const parts = codeContent.split("#code-result");
    if (parts.length < 2) {
      return {
        command: codeContent.trim(),
        result: null,
        language,
        defaultOpen: false
      };
    }
    const resultText = parts[1].trim();
    const defaultOpen = resultText.startsWith("open");
    const cleanResult = defaultOpen ? resultText.slice(4).trim() : resultText;
    return {
      command: parts[0].trim(),
      result: cleanResult,
      language,
      defaultOpen
    };
  };
  const {command, result, language, defaultOpen} = parseChildren();
  const [isOpen, setIsOpen] = useState(defaultOpen);
  if (!result) {
    return children;
  }
  return <div className="codeblock_accordion not-prose mb-4">
      {}
      <div className="[&>*]:!mb-0 [&>*]:!rounded-b-none">
        <CodeBlock language={language} children={command} wrap={wrap} expandable={expandable} />
      </div>

      {}
      <div className="see_results_container border-t-0 bg-gray-100/80 dark:bg-gray-800/80 overflow-hidden" style={{
    marginTop: "-0.25rem"
  }}>
        <button onClick={() => setIsOpen(!isOpen)} className="w-full px-4 py-2.5 flex items-center gap-1 text-left text-[14px] font-medium text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-200/60 dark:hover:bg-gray-700/60 transition-all duration-150" aria-expanded={isOpen}>
          {isOpen ? <Icon icon="caret-down" size="14" iconType="solid" /> : <Icon icon="caret-right" size="14" iconType="solid" />}

          <span>See result...</span>
        </button>

        {isOpen && <div className="[&>*]:!mt-0 [&>*]:!rounded-t-none border-t border-[var(--op-border-ui)] dark:border-[var(--op-border-ui-dark)]">
            <CodeBlock language={resultLang || language} children={result} wrap={wrap} expandable={expandable} />
          </div>}
      </div>
    </div>;
};

When you [use the 1Password desktop app integration to sign in to 1Password CLI](/cli/app-integration/), 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](#specify-an-account-per-command-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`](/cli/reference/commands/signin/) and select the account you want to sign in to from the list of accounts added to your 1Password app.

<CodeResult>
  ```shell highlight={2} theme={null}
  op signin
  #code-result
  Select account  [Use arrows to move, type to filter]
  > ACME Corp (acme.1password.com)
    AgileBits (agilebits.1password.com)
    Add another account
  ```
</CodeResult>

If you don't see the account you want to use, you may need to [add it to the 1Password app](https://support.1password.com/add-account/).

## 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](#find-an-account-sign-in-address-or-id).

For example, to get a list of all vaults in an account with the sign-in address `my.1password.com`:

```shell theme={null}
op vault ls --account my.1password.com
```

You can use the `--account` flag to specify different accounts in scripts. For example:

```shell theme={null}
PASSWORD_1="$(op read --account agilebits-inc.1password.com op://my-vault/some-item/password)"
PASSWORD_2="$(op read --account acme.1password.com op://other-vault/other-item/password)"
```

## 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](#find-an-account-sign-in-address-or-id). You can also use this to specify an account in scripts.

<Tabs groupId="shells">
  <Tab title="Bash, Zsh, sh">
    ```shell theme={null}
    export OP_ACCOUNT=my.1password.com
    ```
  </Tab>

  <Tab title="fish">
    ```shell theme={null}
    set -x OP_ACCOUNT my.1password.com
    ```
  </Tab>

  <Tab title="PowerShell">
    ```powershell theme={null}
    $Env:OP_ACCOUNT = "my.1password.com"
    ```
  </Tab>
</Tabs>

## 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`.

```shell theme={null}
op account list
#code-result
$ op account list
URL                            EMAIL                              USER ID
my.1password.com               wendy.c.appleseed@gmail.com        JDFU...
agilebits-inc.1password.com    wendy_appleseed@agilebits.com      ASDU...
```

You can use the sign-in address listed under `URL` or the unique identifier listed under `USER ID` to refer to the account.

## Learn more

* [Use the 1Password desktop app to sign in to 1Password CLI](/cli/app-integration/)
* [Developer quickstart](/get-started/developer-quickstart)
