Skip to content

Remove 2 leading spaces from cmd suggestion #9252

Closed

Description

@Spacetime99

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

Activity

  1. added
    bug
    on Jan 15, 2026
  2. added
    CLI
    TUI
    on Jan 15, 2026
  3. 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
  4. added
    enhancement
    and removed
    bug
    CLI
    on Jan 15, 2026
  5. ignatremizov commented on Jan 15, 2026

    @ignatremizov

    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
  6. SunRunAway commented on Jan 15, 2026

    @SunRunAway

    It also bites me everytime when I copy things from terminal

  7. emilan commented on Feb 18, 2026

    @emilan

    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'

  8. ignatremizov commented on Feb 18, 2026

    @ignatremizov

    @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

  9. emilan commented on Feb 19, 2026

    @emilan

    @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
    
  10. ahornby commented on Mar 8, 2026

    @ahornby
    Contributor

    @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
    
  11. WAY29 commented on Mar 19, 2026

    @WAY29

    +1

  12. bradmccormick commented on Apr 2, 2026

    @bradmccormick

    +1

  13. 3 remaining items

  14. haydonryan commented on May 23, 2026

    @haydonryan

    Very excited to see movement on this issue - thank you to those commiting!

  15. fcoury-oai commented on May 23, 2026

    @fcoury-oai
    Contributor

    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

  16. haydonryan commented on May 26, 2026

    @haydonryan

    Wasn't aware that raw mode was a feature. That does help. I still question if there's a better way.

  17. youngjoel commented on Jun 4, 2026

    @youngjoel

    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.

    :-)

  18. samronsin commented on Jun 14, 2026

    @samronsin

    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.

  19. devnoname120 commented on Sep 18, 2026

    @devnoname120

    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.

  20. reedlaw commented on Sep 18, 2026

    @reedlaw

    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.

  21. adrianegraphene commented on Sep 18, 2026

    @adrianegraphene

    Yes please to this fix.

  22. etraut-openai commented on Oct 12, 2026

    @etraut-openai
    Contributor

    With the new default fullscreen mode, copy operations no longer include incidental display formatting like spaces, so this is no longer an issue.

  23. samronsin commented on Oct 12, 2026

    @samronsin

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    TUIenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions