Guide · Updated 17 October 2026 · By the makers of Sessions Pro for Codex

Two Codex CLI accounts, one Terminal.

Run codex signed in to your work account in one tab and your personal account in the next, with one environment variable.

Short answer: give each account its own CODEX_HOME folder. Run mkdir -p ~/.codex-work, then CODEX_HOME=~/.codex-work codex in one Terminal tab and sign in with the second account, and keep using plain codex in another tab for the first. Each folder holds its own login, settings and history, so both stay signed in at the same time. Sessions Pro for Codex does the same per profile, and keeps each terminal signed in to the same account as that profile's desktop app.

Free 1-hour preview once you've signed in to a profile. For macOS 14 or later.

Why does the Codex CLI use only one account?

The Codex CLI keeps its login, its settings (config.toml) and its session history in one folder: CODEX_HOME, which is ~/.codex unless you set it. One folder means one login. The Codex in the ChatGPT desktop app uses the same ~/.codex by default, so the CLI and the app share that login too.

How do you set up a second Codex CLI account?

  1. Create a folder for the second account.
    mkdir -p ~/.codex-work
  2. Start codex with CODEX_HOME pointing at it, and sign in.
    CODEX_HOME=~/.codex-work codex
    Sign in with the second account when asked. You do this once per folder.
  3. Use both. In one tab, CODEX_HOME=~/.codex-work codex opens the CLI signed in to the second account. In another, plain codex keeps using ~/.codex and your first account. Both run at the same time.

How do you make it permanent?

Add an alias to ~/.zshrc so you don't have to type the variable:

alias codex-work='CODEX_HOME="$HOME/.codex-work" codex'

Open a new Terminal tab (or run source ~/.zshrc) and codex-work starts the CLI in the second account. Add one alias per account, and create each folder first. To use an account for a whole session, run export CODEX_HOME="$HOME/.codex-work" in that tab: every codex command there uses that folder until you close it.

What should you copy between the folders?

  • Copy config.toml if you want the same settings, such as MCP servers, in both accounts: cp ~/.codex/config.toml ~/.codex-work/.
  • Don't copy auth.json. It holds the login; copying it puts the first account into the second folder.
  • Leave the history where it is. Each folder keeps its own sessions, so each account's history stays with it.

What errors will you run into?

  • CODEX_HOME points to "/Users/you/.codex-work", but that path does not exist. The folder hasn't been created. Run mkdir -p on it and try again.
  • Signed in to the wrong account. Check which folder the tab uses with echo $CODEX_HOME. If it prints nothing, the tab uses ~/.codex.
  • Logging out signed out something else. codex logout clears the login of the current CODEX_HOME, so with a shared ~/.codex it also signs out other terminals and, by default, the desktop app's Codex. See why codex logout signs you out everywhere.

What about the ChatGPT desktop app?

CODEX_HOME separates the command line only. The desktop app keeps using ~/.codex, so plain codex and the app share one account while ~/.codex-work stays CLI-only. ChatGPT's web account switcher doesn't help here either, since it doesn't touch the CLI (more on the switcher). To get the app per account too, each account needs its own copy of the app; our guide has the free Terminal method.

Sessions Pro for Codex does both. Each profile is its own copy of the ChatGPT app, and “Open Codex CLI in Terminal” runs codex with that profile's own CODEX_HOME, so the terminal and the app are always signed in to the same account.

A Sessions Pro for Codex profile, Codex Work, with the Open Codex CLI in Terminal button
CODEX_HOME by handSessions Pro for Codex
Two CLI accounts at once✓✓
Desktop app per account✕✓
CLI signed in to the same account as the appOnly for ~/.codex✓ Every profile
Setupmkdir and an aliasCreate a profile, sign in
CostFree$24.99 one-time

We make Sessions Pro for Codex.

Sessions Pro for Codex
$24.99one-time

Free 1-hour preview once you've signed in to a profile. For macOS 14 or later.

On Windows? The same setup in PowerShell, cmd and Windows Terminal: two Codex accounts on Windows. Comparing every approach, including scripts and browser profiles? See the best ways to run multiple Codex accounts, compared.

FAQ

How do I use two Codex CLI accounts at the same time?

Give each account its own CODEX_HOME folder. Create it with mkdir -p ~/.codex-work, run CODEX_HOME=~/.codex-work codex and sign in once. Plain codex keeps using ~/.codex, so both accounts can run in separate tabs.

Where does the Codex CLI keep its login?

In CODEX_HOME, which is ~/.codex unless you set it. By default the login is saved in auth.json in that folder.

Sessions Pro for Codex is made by LEX GLOBAL IT S.R.L. and is not affiliated with, endorsed by or sponsored by OpenAI. It runs the official ChatGPT app with accounts you already have, and OpenAI's terms apply to each account. ChatGPT and Codex are trademarks of OpenAI.