Windows: allow configuring the default session shell via config
Summary
Codex currently defaults to PowerShell for the Windows session shell path. That makes it hard for users who primarily work in Git Bash or another already-supported shell to make that shell the default for Codex sessions.
I prepared a change that adds an explicit Windows config entry:
[windows]
shell_path = "C:\\Program Files\\Git\\bin\\bash.exe"
When windows.shell_path is configured, Codex uses that executable as the default session shell. When it is not configured, the current behavior remains unchanged and Windows still falls back to PowerShell.
Why this approach
I intentionally implemented this as an explicit config option rather than automatic shell detection:
- Windows does not have a single reliable equivalent to Unix
$SHELL - multiple
bash.exevariants may exist on PATH (Git Bash, WSL, MSYS2, etc.) - explicit configuration is easier to reason about and avoids changing behavior for existing users
Implementation notes
The change currently does the following:
- adds
windows.shell_pathto config parsing - supports
profile.windows.shell_pathoverriding the top-level value - validates the configured executable against Codex's existing built-in shell detection/execution logic
- uses the configured shell as the default session shell when no internal
user_shell_overrideis provided - updates the Windows shell tool descriptions so they refer to the configured default shell rather than hardcoding PowerShell wording
- updates docs and regenerates
config.schema.json
This does not try to add arbitrary shell adapter support. The configured path must resolve to a shell executable already supported by Codex's built-in shell handling.
Testing performed
I ran:
cargo +stable test -p codex-toolscargo +stable test -p codex-core config::tests::config_loads_windows_shell_path_from_toml -- --exact --nocapturecargo +stable test -p codex-core config::tests::profile_windows_shell_path_overrides_top_level_value -- --exact --nocapturecargo +stable test -p codex-core config::tests::invalid_windows_shell_path_fails_config_load -- --exact --nocapturecargo +stable test -p codex-core shell::tests::configured_windows_shell_path_uses_bash -- --exact --nocapturecargo +stable test -p codex-core shell::tests::invalid_windows_shell_path_is_rejected -- --exact --nocapturecargo +stable test -p codex-core shell::tests::finds_powershell -- --exact --nocapturecargo +stable test -p codex-core shell::tests::detects_powershell_as_default -- --exact --nocapture
Branch / commit
I could not open a PR directly because the repository currently limits PR creation to collaborators.
The proposed change is available here:
- branch:
LXL47/codex:feat/windows-shell-path-config - commit:
0d9010493
If this direction is acceptable, I can keep the branch available for maintainers to review or cherry-pick from.
5 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
A few implementation details that may help with review:
codex-rs/config/src/types.rswindows.shell_pathtoWindowsTomlcodex-rs/core/src/config/mod.rsprofile.windows.shell_pathbefore the top-levelwindows.shell_pathcodex-rs/core/src/codex.rsuser_shell_overridestill wins if one is already provided programmaticallycodex-rs/core/src/shell.rscodex-rs/tools/src/local_tool.rsdocs/config.mdandcodex-rs/core/config.schema.jsonA couple of scope boundaries are intentional here:
windows.shell_pathmust point to a shell executable already handled by Codex's built-in shell adaptersbash,sh,zsh,pwsh,powershell, andcmdwindows.shell_pathis unset, Windows behavior remains the same as todayI also added targeted coverage for:
windows.shell_pathfrom configbash.exeJust dropping a +1 with a real consumer use case. I maintain winuxsh (https://github.com/unixwin/winuxsh), a Windows-native bash/zsh-like shell (rubash + winuxcmd, no MSYS/Cygwin/WSL layer). We have already verified that
winuxsh -c "<cmd>"meets the agent non-interactive contract: no banner, clean stdout/stderr, exact exit code, native Windows paths and~resolution. We have users who would switch to Codex specifically if shell_command could route to winuxsh instead of PowerShell.Everything your PR proposes is exactly what we need:
windows.shell_path = "..."as the single config entry pointOne thing worth confirming: my winuxsh uses
-c "<command>"for non-interactive mode (same as bash/zsh). Looking at codex-rs/core/src/shell.rs, derive_exec_args currently branches on ShellType and would route a custom path through the Cmd branch (/c <command>) if detect_shell_type falls back. Would the PR validation reject an unknown stem like winuxsh.exe, or is there room to add a bash/sh-compatible branch (i.e. -c rather than /c) when the configured path matches a known Unix-style shell?Happy to help test a build or contribute test cases if it helps move this forward.
I would strongly benefit from this feature, specifically with Cygwin Bash:
I launch Codex from Cygwin, but native Windows Codex still runs agent commands through PowerShell. I can instruct it to invoke Cygwin Bash for each command, but that is not an equivalent substitute for making Bash the actual session shell.
Claude Code supports this workflow through
CLAUDE_CODE_GIT_BASH_PATH, and I use it successfully withC:\cygwin64\bin\bash.exe. Commands run directly in Cygwin, so POSIX scripts, paths, tools, skills, and permission rules behave consistently.The PowerShell-to-Bash wrapper approach has several drawbacks:
scripts/directories fragile, because a script may accidentally be sent directly to PowerShell.WSL is not a drop-in replacement for every Windows-native project. Keeping a repository on
C:\...while running Linux tools can cause significant cross-filesystem I/O overhead. Moving a project into WSL can also require changes to paths, toolchains, editor and debugger setup, environment variables, services, and Windows-specific build or automation dependencies.Cygwin is the best fit for some of my existing Windows-native projects. Please consider accepting a Cygwin
bash.exepath forwindows.shell_path, provided it passes the existing Bash shell detection and execution checks.I'd also support this. My main reasons are:
There are also a couple of closely related issues:
So I think an explicit
windows.shell_pathas proposed here would be a useful and fairly general solution, while preserving PowerShell as the default for existing users.