Save multiple OpenAI Codex login sessions and switch between them instantly with a single command — no re-login required.
Supports Windows, Linux, and macOS.
Git is required. No Git? See how to install it here
Each Codex account's auth token is saved as its own isolated profile — they never interfere with each other.
cx switch opens an interactive menu. Pick an account, press Enter, and Codex restarts under the new profile automatically.
After each Codex session ends, usage limits are scanned automatically. See at a glance which accounts are capped and when they reset.
Config, hooks, and session history are shared across all profiles. Only the auth token changes — everything else stays untouched.
| Item | Location | Switched / Shared |
|---|---|---|
| Account auth token | ~/.codex/auth.json | switched per profile |
| Config, hooks | ~/.codex/config.toml, hooks.json | shared |
Sessions, /resume history, sqlite state | ~/.codex/ | shared |
| skills, plugins | ~/.codex/ | shared |
auth.json (the account token) is switched; everything else is shared. Launching through the codex wrapper runs against the normal ~/.codex, so conversations, /resume and config stay shared across accounts.cx login signs in inside an isolated temporary home and never touches your other saved accounts — so multiple accounts (including several workspaces under one ChatGPT account) coexist without logging each other out.
Press Win + X, choose "Windows PowerShell" or "Terminal", then paste the full command below (Ctrl+V) and press Enter.
PS> irm https://raw.githubusercontent.com/yazelin/codex-auth-switcher/main/install-oneliner.ps1 | iex
Once installation completes, the terminal will print next-step instructions automatically.
If you are already logged in to Codex, run this command to save the existing session as a profile named "main":
PS> cx import main
"main" is just a name — feel free to use your own name or any nickname you prefer.
Run cx login followed by the profile name you want. The Codex login window will open:
PS> cx login work
# After login completes, the "work" profile is saved
PS> cx list
CURRENT PROFILE LOGIN EMAIL PLAN LIMIT
* main ok ma***@gmail.com plus -
work ok wo***@company.com team -
* marks the currently active account.
This is the recommended way to switch — it automatically closes any running Codex before switching:
PS> cx switch
PS> codex
Always launch via codex (not the original codex.exe directly) so that account switching takes effect.
$ bash <(curl -fsSL https://raw.githubusercontent.com/yazelin/codex-auth-switcher/main/install-oneliner.sh)
$ source ~/.bashrc
# zsh users: run source ~/.zshrc instead
$ cx import main # save existing account
$ cx login work # add a second account
$ cx use work # switch to the work account
$ codex # launch Codex
Blue highlight = currently selected account / * = currently active / !hit = usage limit reached
| Command | Description |
|---|---|
cx switch [--live]NEW | Interactive menu to switch accounts; automatically closes Codex first. --live refreshes usage before displaying. |
cx killNEW | Immediately terminate all running Codex processes |
cx import <name> | Save the current login session as a named profile |
cx login <name> | Open the Codex login flow and save credentials as a new profile |
cx use <name> | Switch the shared active profile |
cx list [--live] | List all profiles and their status. --live refreshes usage first. |
cx usage [name|--all] | Fetch live usage; updates all profiles when called without arguments |
cx info [name] | Show detailed information for a single profile |
cx current | Print the name of the currently active profile |
cx remove <name> | Delete a profile |
cx ps | Show currently detected Codex processes |
cx doctor | Diagnostic tool: shows paths, process status, and profile overview |
cx export profiles.tgz | Back up all profiles to a compressed archive |
cx restore profiles.tgz | Restore profiles from a compressed archive |
cx ok <name> | Manually clear the usage-limit flag for a profile |
cx help | Show built-in command reference |
codex | Launch Codex under the currently active profile |
Windows: Run this in PowerShell:
Close and reopen PowerShell after installation — git will then be available.
Linux (Ubuntu/Debian):
macOS: Type git in the terminal — macOS will automatically prompt you to install Xcode Command Line Tools.
Windows sometimes blocks PowerShell scripts from running. Run this line first to lift the restriction, then re-paste the install command:
The installer adds the configuration to your PowerShell profile, but a new PowerShell window is needed for the change to take effect. If it still does not work, verify that your profile file contains the correct line:
It should contain a line like . "C:\Users\YourName\codex-auth-switcher\shell\powershell.ps1". If it is missing, add it manually, save the file, and reopen PowerShell.
cx switch requires an interactive terminal window (Windows Terminal, PowerShell window, etc.). It cannot run inside VS Code's Output panel or a CI environment.
Alternative: use cx use <name> to switch directly without the interactive menu.
Yes. When launched via the codex wrapper, Codex uses the standard ~/.codex directory, so you can open two or three windows under the same active profile and they will share the /resume history. Commands that modify auth.json — such as cx use and cx login — are blocked while Codex is running to prevent mid-session account changes.
No. All auth tokens are stored only in the ~/.codex_auth_profiles/ folder on your own machine and are never sent to any server. This tool runs entirely locally.
Do not commit the ~/.codex_auth_profiles/ folder to any Git repository.
The account has reached Codex's usage limit. The displayed time is when the limit resets. After the reset, cx list will clear the flag automatically.
If the limit has already reset but the flag persists, clear it manually: cx ok <name>