字
字节笔记本
2026年2月22日
OpenAI Codex CLI 增强脚本:cdx 命令封装
本文介绍 OpenAI Codex CLI 的增强脚本,由 Ian Nuttall 分享。该脚本提供了便捷的 cdx 命令封装,支持 GPT-5 模型,并包含自动确认模式(yolo 模式),让 AI 编程助手的使用更加高效。
脚本功能
该 Gist 包含三个版本的脚本,分别适用于不同的使用场景:
1. codex-gpt-5-codex.sh - GPT-5 Codex 增强版
适用于需要使用 GPT-5 Codex 模型的场景,包含实验性的 reasoning summary 功能。
bash
# from: <https://x.com/iannuttall/status/1965090297630826931>
cdx() {
if [[ "$1" == "update" ]]; then
npm install -g @openai/codex@latest
else
codex -m gpt-5-codex --yolo -c model_reasoning_effort="high" -c model_reasoning_summary_format=experimental --search "$@"
fi
}
# Note: with auto confirmation. use at your own risk. thanks!2. codex-yolo.sh - YOLO 自动确认版
标准 GPT-5 模型的自动确认版本,适合信任 AI 决策的开发者。
bash
# from: <https://x.com/iannuttall/status/1965090297630826931>
cdx() {
if [[ "$1" == "update" ]]; then
npm install -g @openai/codex@latest
else
codex -m gpt-5 --yolo -c model_reasoning_effort="high" --search "$@"
fi
}
# Note: with auto confirmation. use at your own risk. thanks!3. codex.sh - 标准版
基础版本,不包含自动确认,需要手动确认每个操作。
bash
# from: <https://x.com/iannuttall/status/1965090297630826931>
cdx() {
if [[ "$1" == "update" ]]; then
npm install -g @openai/codex@latest
else
codex -m gpt-5 -c model_reasoning_effort="high" --search "$@"
fi
}使用方法
将脚本内容添加到您的 shell 配置文件中:
bash
# 对于 zsh 用户
echo '上述脚本内容' >> ~/.zshrc
source ~/.zshrc
# 对于 bash 用户
echo '上述脚本内容' >> ~/.bashrc
source ~/.bashrc命令用法
bash
# 使用 GPT-5 进行 AI 编程(根据选择的版本)
cdx "你的编程需求描述"
# 更新 Codex CLI 到最新版本
cdx update参数说明
| 参数 | 说明 |
|---|---|
-m gpt-5 / -m gpt-5-codex | 指定使用的模型 |
--yolo | 启用自动确认模式(无需人工确认) |
-c model_reasoning_effort="high" | 设置推理努力程度为高 |
-c model_reasoning_summary_format=experimental | 启用实验性推理摘要格式 |
--search | 启用搜索功能 |
注意事项
- 自动确认风险:使用
--yolo模式时,AI 将自动执行操作而无需确认,请谨慎使用 - 模型选择:
gpt-5-codex是专门针对编程优化的模型版本 - 更新维护:使用
cdx update可快速更新 Codex CLI
来源
- 原作者:Ian Nuttall (@iannuttall)
- 原推文:https://x.com/iannuttall/status/1965090297630826931
- Gist 作者:@imWildCat
分享: