Remove 2 leading spaces from cmd suggestion
What version of Codex is running?
codex-cli 0.80.0
What subscription do you have?
ChatGPT+
Which model were you using?
5.2
What platform is your computer?
Linux 6.14.0-34-generic x86_64 x86_64
What terminal emulator and version are you using (if applicable)?
MacOS Terminal
What issue are you seeing?
When codex suggests a cmd to run, e.g. inline PY or a cmd line with a line wrap, the simple copy / paste fails because there are 2 leading spaces indenting each output line. So these will split up things like URL's that should be a single string. Here's an example:
Run it the same way:
/home/spacetime/codex/scripts/run_single_story_extract.sh /home/spacetime/codex/datasets/news_ingest/news_reports_20260110T030329Z.jsonl https://www.pennlive.com/news/2026/01/anti-ice-
protesters-assemble-in-harrisburg-as-fallout-from-minnesota-shooting-grows.html
anti-ice-protestors, gets 2 spaces inserted after ice-
What steps can reproduce the bug?
Just ask it to suggest a cmd line that line wraps on a couple or more lines, where the spaces will interrupt it.
What is the expected behavior?
No spaces to indent multi line cmd's, place them all on the left, slighly less pretty, but much more functional
Additional information
No response
This is also on Windows Terminal (WSL Ubuntu) too.
My current workaround is to copy, paste into VSCode, and use the shift+alt drag for multi-cursor select all lines with two spaces or none, press Space then Backspace (since not all cursors have selected the two spaces prefixes per line). Now I have a clean command to copy-paste.
https://github.com/user-attachments/assets/c6705281-f3a3-4b19-8c3b-aaef2a8efab9
It also bites me everytime when I copy things from terminal
Here's a workaround I just came up with. I run it in another terminal after the agent has finished responding, and I get its last message without the extra indentation. Then I can copy properly from there. Helps both with indentation issues and when codex outputs what should be long one-liners. Not a solution, but a good enough workaround for me.
tail -n1 $(ls -t ~/.codex/sessions/*/*/*/*.jsonl | head -n1) | jq -r '.payload.last_agent_message'
@emilan I wonder if you could pipe that into clipboard with an extra regex... On windows git bash you can echo text | clip.exe, not sure about equivalent macos/Linux... but I imagine it's possible to create a "copy commands to clipboard" Skill and just let codex get the command copied directly
@emilan I wonder if you could pipe that into clipboard with an extra regex... On windows git bash you can
echo text | clip.exe, not sure about equivalent macos/Linux... but I imagine it's possible to create a "copy commands to clipboard" Skill and just let codex get the command copied directly
Any terminal emulator that supports OSC52 can be told to put data in the system clipboard. For desktop terminal emulators like Windows Terminal, this means it will be put in the Windows clipboard. This also works fine in SSH sessions, containers, etc, also when started from WSL.
Put this little helper on your target (e.g. in .bashrc):
clip ()
{
local b64;
b64=$(base64 | tr -d '\n');
printf '\e]52;c;%s\a' "$b64"
}
Then invoke it like
my-cmd | clip
@etraut-openai might you be interested in a PR to make the indent configurable? Copy/pasting shell commands from codex was bugging me so I addressed it locally by adding a config for the indent in https://github.com/ahornby/codex/commit/28dc14792b5657188919371eff362dd3c34671b2
Before, spaces break here document terminator:
$ codex "show me a simple bash shell command using a here document"
╭─────────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.111.0) │
│ │
│ model: gpt-5.3-codex /model to change │
│ directory: ~/local/codex/codex-rs │
╰─────────────────────────────────────────────╯
Tip: New Use /fast to enable our fastest inference at 2X plan usage.
› show me a simple bash shell command using a here document
• cat <<'EOF'
Hello from a here document.
EOF
Token usage: total=5,783 input=5,762 (+ 6,528 cached) output=21
After, no spaces:
$ ./target/debug/codex -c tui.continuation_indent=0 "show me a simple bash shell command using a here document"
╭─────────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.0.0) │
│ │
│ model: gpt-5.3-codex /model to change │
│ directory: ~/local/codex/codex-rs │
╰─────────────────────────────────────────────╯
Tip: This is a test announcement
› show me a simple bash shell command using a here document
• cat <<'EOF'
Hello from a here document.
This is line 2.
EOF
Token usage: total=5,550 input=5,523 (+ 6,656 cached) output=27
+1
+1
Please guys downvote to hell @etraut-openai because he says this is by "design" and closed as no planned...
https://github.com/openai/codex/issues/16431#issuecomment-4174267698
What a joke CLI without basic features when others have this fixed from beggining, Opencode is years light better than Codex in UI design.
Very excited to see movement on this issue - thank you to those commiting!
Very excited to see movement on this issue - thank you to those commiting!
Did you try raw mode? Default keymap is alt-r but you can remap it with /keymap
Wasn't aware that raw mode was a feature. That does help. I still question if there's a better way.
the /raw support unblocks but as put in a conversation with gemini: ok. Now option-r works to switch to raw mode. So I can get ugly but can copy and paste and pretty but deadly time-wasting trap.
Exactly! You have summed it up perfectly: "Ugly but functional" vs. "Pretty but a deadly time-wasting trap."It is a frustrating trade-off, but at least you can now use Option + R like a quick toggle switch. Press it to drop into "ugly mode" right before you drag-select your text, copy it, and then instantly press it again to return to the cleaner layout view.
:-)
Thank you very much @fcoury-oai for the raw mode, this is very useful ! Would you consider a follow-up to make fenced shell-like command blocks copy cleanly while leaving the rest of the response in rich mode ?
Suggested shape:
- Detect fenced code blocks whose info string is shell-like, e.g.
sh,bash,zsh,shell,console,terminal,powershell,pwsh,ps1,cmd,bat. - Keep using the existing syntax-highlighted code-block renderer for those blocks.
- Mark the rendered lines as copy-sensitive command lines.
- Skip the assistant gutter (
•/ two-space continuation padding) for those lines only. - Preserve each source command line as one logical line and let the terminal soft-wrap long lines where possible, rather than hard-wrapping them before insertion into scrollback.
- Apply this to both streamed output and finalized history cells.
This should fix common heredoc and multiline-command cases without forcing the entire transcript into /raw.
On iTerm2 (and any decent terminal) you can press cmd-option while selecting text in order to select a rectangle instead of entire lines. Solves the problem completely and I don’t see why Claude should downgrade its TUI to accommodate your lack of understanding of the basic controls of your terminal.
On iTerm2 (and any decent terminal) you can press cmd-option while selecting text in order to select a rectangle instead of entire lines. Solves the problem completely and I don’t see why Claude should downgrade its TUI to accommodate your lack of understanding of the basic controls of your terminal.
Funny you should mention Claude, because Claude handles this perfectly. Its code blocks are indented, yet ordinary cursor selection does not start at the beginning or include two-space indents. Not only that, selection copies text automatically so no keyboard shortcuts are needed at all.
Yes please to this fix.
With the new default fullscreen mode, copy operations no longer include incidental display formatting like spaces, so this is no longer an issue.
Hello, thank you @etraut-openai for the update. Sorry to be that guy, but for us --no-alt-screen (also tui.alternate_screen = "never") people, this issue is still relevant.
Glad to read that the fullscreen mode solves the issue though, will give it a second chance.