Skip to content

bashar94/codex-cli-account-switcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Codex Accounts Switcher ๐ŸŒ€

Easily manage multiple OpenAI Codex CLI accounts โ€” switch, save, and restore with one command.

The official OpenAI Codex CLI does not support multi-account login.
Users must manually swap ~/.codex folders or re-authenticate every time they switch accounts โ€” a painful process for developers who use multiple OpenAI accounts (for example, personal vs work).

I raised this issue here: #4432
and also created a pull request adding multi-account support: #4457
However, the feature hasnโ€™t yet been merged or prioritized, so this standalone script fills that gap.

I HAVE TESTED THIS ON MAC ONLY


๐Ÿ”ง Installation

# Clone and install
git clone https://github.com/bashar94/codex-cli-account-switcher.git
cd codex-accounts-switcher
chmod +x codex-accounts.sh

# Optionally make it global
sudo mv codex-accounts.sh /usr/local/bin/codex-accounts

๐Ÿš€ Usage

codex-accounts list
codex-accounts current
codex-accounts save <name>
codex-accounts add <name>
codex-accounts switch <name>

Examples

# Save your current login
codex-accounts save bashar

# Add a new account slot
codex-accounts add tazrin
codex login   # then run:
codex-accounts save tazrin

# Switch between accounts
codex-accounts switch bashar

๐Ÿ“ Data Locations

Codex stores its session data inside ~/.codex. This script backs up each accountโ€™s .codex directory as a compressed zip file and lets you swap them instantly.

Path Purpose
~/.codex Active Codex session folder
~/codex-data/<name>.zip Saved account backups
~/.codex-switch/state Tracks current and previous accounts

Itโ€™s safe to use โ€” your Codex configuration is preserved before every switch.

โš™๏ธ Requirements

  • macOS / Linux
  • zip, unzip, bash
  • Codex CLI installed:
    • macOS: brew install codex
    • Linux: use your package manager or follow the Codex CLI docs

๐Ÿง  Notes

  • Supports unlimited accounts โ€” name-based switching.
  • Automatically backs up the current account before changing.
  • Shows the current and previous account states.
  • Works cross-platform: macOS, Linux, WSL.
  • Simple shell-only dependencies (bash, zip, unzip).
  • Helpful prompts if Codex isnโ€™t installed or logged in yet.
  • You can safely share this across machines (just copy ~/codex-data).

About

Easily switch between multiple OpenAI Codex CLI accounts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages