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_
14 Comments
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 directlyAny 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):
Then invoke it like
@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:
After, no spaces:
+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!
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:
sh,bash,zsh,shell,console,terminal,powershell,pwsh,ps1,cmd,bat.•/ two-space continuation padding) for those lines only.This should fix common heredoc and multiline-command cases without forcing the entire transcript into
/raw.