gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Code blocks as delivered in Gemini CLI are unusable

Open martinysteen opened this issue 1 year ago • 7 comments

What happened?

Using Gemini CLI in Windows Command Box (and Windows Powershell) under Win11 suffers from a serious flaw: In code blocks offered line numbers and indentation spaces/tabs are added. This makes simple copy/paste to your own use impossible. Code can only be used after manual editing each line. This alone will hinder my use of a CLI tool and instead use a GUI version.

What did you expect to happen?

To Windows users I expect Gemini CLI to offer code output without added line numbers and indentation characters. It should be just as usefull as when using GUI-based code blocks.

Client information

  • CLI Version: 0.1.7
  • Git Commit: 55cc809
  • Operating System: win32 v22.17.0
  • Sandbox Environment: no sandbox
  • Model Version: gemini-2.5-flash
  • Memory Usage: 163.4 MB

Login information

OAuth

Anything else we need to know?

Besides this annoyance the experience was excellent. I got all what I came for.

martinysteen avatar Jul 04 '25 18:07 martinysteen

Have you tried directing Gemini to write a code block to a file called my_block.txt, and it will format it correctly?

benmordecai avatar Jul 04 '25 18:07 benmordecai

Yes. I found out to circumvent the problem that way. After many hours of chatting. And Gemini itself never proposed it so I still think it is important to solve.

Den fre. 4. jul. 2025 kl. 20.47 skrev Ben Mordecai @.***

:

benmordecai left a comment (google-gemini/gemini-cli#3257) https://github.com/google-gemini/gemini-cli/issues/3257#issuecomment-3037055434

Have you tried directing Gemini to write a code block to a file called my_block.txt, and it will format it correctly?

— Reply to this email directly, view it on GitHub https://github.com/google-gemini/gemini-cli/issues/3257#issuecomment-3037055434, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUUZ7LHXPA4CFBIAG5UMBW33G3D5HAVCNFSM6AAAAACAZ65GM2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMZXGA2TKNBTGQ . You are receiving this because you authored the thread.Message ID: @.***>

martinysteen avatar Jul 04 '25 19:07 martinysteen

This issue is present as well in linux

Image

Also in packages/cli/src/ui/utils/CodeColorizer.tsx check lines 147-149 :

              <Text color={activeTheme.colors.Gray}>
                {`${String(index + 1 + hiddenLinesCount).padStart(padWidth, ' ')} `}
              </Text>

and 175-177:


            <Text color={activeTheme.defaultColor}>
              {`${String(index + 1).padStart(padWidth, ' ')} `}
            </Text>

jwgcurrie avatar Jul 04 '25 19:07 jwgcurrie

This is extremely annoying and we shouldnt need to ask gemini to do that and spend more tokens to fix the problem. Its a simple matter of UX design.

AFMiziara avatar Jul 07 '25 19:07 AFMiziara

I agree. It would be nice also if as a general ui enhancement you could have a configurable history of prompts, responses, and generated blocks. Maybe you could do some things with slash commands like /#mytag as a bookmark to easily find something from a session (persisting between sessions) or /rawblock to give the raw block without line numbering.

In most cases the line numbering and border are a good thing since they enhance clarity. UNLESS you are intending to copy and paste the block.

benmordecai avatar Jul 07 '25 19:07 benmordecai

Yes, especially if the command it's telling me to do (for instance sudo, so it can't do itself due to password) is multiline, no way to copy and paste into other terminal. I have to copy, paste somewhere, find all the weird formatting and then paste into other terminal. Usually not a big deal, but seems like an obvious thing to have from the git go.

AltFl0w avatar Jul 22 '25 11:07 AltFl0w

Hello! As part of our effort to keep our backlog manageable and focus on the most active issues, we are tidying up older reports.

It looks like this issue hasn't been active for a while, so we are closing it for now. However, if you are still experiencing this bug on the latest stable build, please feel free to comment on this issue or create a new one with updated details.

Thank you for your contribution!

gemini-cli[bot] avatar Dec 03 '25 21:12 gemini-cli[bot]