Disclosure up front: I build Sessions Pro for Codex, a paid app that does this for you. Everything until the last section is free and only needs Terminal. The commands were run on macOS 26 with ChatGPT 26.1021.
If you use Codex for a client or an employer and also have your own ChatGPT account, you've probably hit this: the ChatGPT desktop app (which absorbed the Codex app in July) is signed in to one account at a time. Switching means signing out, signing back in, and losing your place.
ChatGPT now has a built-in account switcher, but it only works on the web version, which doesn't help if you build real projects in the desktop app. So here's what actually decides the account in the desktop app, and the ways around it.
What decides which account the app uses
Two folders, not one:
| What | Default location | Holds |
|---|---|---|
CODEX_HOME |
~/.codex |
auth.json (the Codex login), config.toml (settings, MCP servers), state_5.sqlite (threads), .codex-global-state.json (pins, projects, ordering) |
| App data | ~/Library/Application Support/Codex |
The app's own (Electron) data: the web session, preferences, caches |
One pair of folders, one account. The app is still com.openai.codex under the hood, and the Codex CLI reads the same ~/.codex, so by default the app and codex in your terminal share one login. That's also why codex logout in a terminal can sign the app out.
Free method 1: a second copy of the app from Terminal
The app reads CODEX_HOME for Codex's state, CODEX_ELECTRON_USER_DATA_PATH for its app data, and also takes Chromium's --user-data-dir. Point all three at new folders and open -n starts a second, independent copy next to the first:
mkdir -p "$HOME/.codex-work" "$HOME/Library/Application Support/Codex-Work"
open -n -a ChatGPT \
--env CODEX_HOME="$HOME/.codex-work" \
--env CODEX_ELECTRON_USER_DATA_PATH="$HOME/Library/Application Support/Codex-Work" \
--args --user-data-dir="$HOME/Library/Application Support/Codex-Work"
The new window starts signed out (there's no auth.json in the new folder yet). Sign in to the second account there, and from then on that pair of folders stays signed in to it.
Two details I found while testing:
-
Both copies can run together. The app only takes its single-instance lock per data folder when
CODEX_ELECTRON_USER_DATA_PATHis set, so separate folders never block each other. -
Create the folders first.
openwon't, and Codex expectsCODEX_HOMEto exist.
The catches:
- Both copies look identical. Same name, same Dock icon, two "ChatGPT" entries in ⌘-Tab. Telling work from personal means checking the account in each window.
-
codex://links go to whichever copy started last. Every copy registers itself forcodex://when it launches. Thread links and connector sign-in callbacks (OAuth) can land in the wrong account. - You start it from Terminal every time. Double-clicking ChatGPT opens your default account. A shell alias or an Automator app helps.
-
Don't seed it with a copy of
~/.codex. Some files inside hold absolute paths to the original folder, so continuing a copied thread can write into your original account's history. Start the second folder empty and sign in.
Free method 2: just the Codex CLI, with CODEX_HOME
If you only need the second account in the terminal, it's simpler: one folder per account.
mkdir -p ~/.codex-work
CODEX_HOME=~/.codex-work codex login # sign in with the other account once
CODEX_HOME=~/.codex-work codex login status
# Not logged in -> before signing in
# Logged in using ChatGPT
Plain codex keeps using ~/.codex and your first account. Add an alias so you don't have to type the variable:
alias codex-work='CODEX_HOME="$HOME/.codex-work" codex'
Each folder has its own config.toml, so MCP servers and settings are per account. Copy config.toml across if you want the same setup, never auth.json. And logout is per folder too: codex-work logout signs out only the work account.
Other options, briefly
- Sign out and back in: fine once a week, painful several times a day, and your threads view changes with every switch.
- A browser profile per account: works with ChatGPT on the web, but not with the desktop app's local Codex threads, projects and terminal.
- A second macOS user: complete separation, but only one account in front of you at a time, and fast user switching between them.
What I ended up building
Method 1 works, but its catches add up if you switch accounts every day: two identical Dock icons, thread links opening in the wrong account, and re-running the command after every reboot. That's what I built Sessions Pro for Codex (Mac and Windows) to fix:
- Each account becomes its own app, with its own name, colored Dock icon and place in ⌘-Tab.
-
codex://links go to the account you were last using, not to whichever copy started last. - Each profile has its own Codex CLI (
CODEX_HOME), opened from the app with one click. - A menu bar switcher, and a meter showing each account's Codex session and weekly usage.
- It keeps ChatGPT itself up to date (checking OpenAI's signature first) and rebuilds every profile from the new version, since copies don't update themselves.
It's $24.99 one-time for two computers, with a 1-hour free preview. If the free methods above are enough for you, use them: they're genuinely fine for occasional switching.
A note on the rules: these methods run the official ChatGPT app with accounts you already have, like a work and a personal account. OpenAI's terms still apply to each account, and none of this is meant for getting around usage limits.
The full guide, with a comparison table of every method, is on multiplecodex.com.
Top comments (0)