You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Reacted by Ignat Remizov, Feng Liyuan, Alex Hornby, Umaru, Wouter Coppieters, kurkuruzo, ynn, Cyril Combe, jabbahudson, Storhemulen and 82 more
changed the title [-]On MacOS terminal, every suggest codex cmd has 2 leading spaces, thus stopping copy / paste abiity for multi line statements[/-][+]Remove 2 leading spaces from cmd suggestion[/+]on Jan 15, 2026
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.
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.
@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):
@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 ahornby@28dc147
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
Reacted by Haydon Ryan, Artur Wyszyński, Joel Young, Daniel Juárez, clee7-sc and Reed G. Law
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.
Reacted by Louis Delille, Adam Nellis, João D. Ferreira, weakfl and Reed G. Law
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.
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.
Activity
[-]On MacOS terminal, every suggest codex cmd has 2 leading spaces, thus stopping copy / paste abiity for multi line statements[/-][+]Remove 2 leading spaces from cmd suggestion[/+]ignatremizov commentedon Jan 15, 2026
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.
Screen.Recording.2026-01-15.at.10.40.37.mov
SunRunAway commentedon Jan 15, 2026
It also bites me everytime when I copy things from terminal
emilan commentedon Feb 18, 2026
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'ignatremizov commentedon Feb 18, 2026
@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 directlyemilan commentedon Feb 19, 2026
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):
Then invoke it like
ahornby commentedon Mar 8, 2026
@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 ahornby@28dc147
Before, spaces break here document terminator:
After, no spaces:
WAY29 commentedon Mar 19, 2026
+1
bradmccormick commentedon Apr 2, 2026
+1
3 remaining items
haydonryan commentedon May 23, 2026
Very excited to see movement on this issue - thank you to those commiting!
fcoury-oai commentedon May 23, 2026
Did you try raw mode? Default keymap is alt-r but you can remap it with /keymap
haydonryan commentedon May 26, 2026
Wasn't aware that raw mode was a feature. That does help. I still question if there's a better way.
youngjoel commentedon Jun 4, 2026
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.
:-)
samronsin commentedon Jun 14, 2026
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.feat(tui): add raw scrollback mode (openai#20819)
devnoname120 commentedon Sep 18, 2026
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.
reedlaw commentedon Sep 18, 2026
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.
adrianegraphene commentedon Sep 18, 2026
Yes please to this fix.
etraut-openai commentedon Oct 12, 2026
With the new default fullscreen mode, copy operations no longer include incidental display formatting like spaces, so this is no longer an issue.
samronsin commentedon Oct 12, 2026
Hello, thank you @etraut-openai for the update. Sorry to be that guy, but for us
--no-alt-screen(alsotui.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.