Weird characters when pasting in WIndows Terminal #14413

Closed
opened 2026-01-31 04:09:36 +00:00 by claunia · 10 comments
Owner

Originally created by @speller on GitHub (Jul 7, 2021).

Windows Terminal version (or Windows build number)

1.8.1521.0, 10.0.21390.2025

Other Software

No response

Steps to reproduce

When I run the following command in Ubuntu 20 from under Windows Terminal:

docker run -ti --name gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk:alpine gcloud auth login

I'm getting the following input when pasting the key:

Go to the following link in your browser:

    https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=<long URL>

Enter verification code: ^[[200~<real pasted text>^[[201~

The command fails to process this input. I'm pasting the <real pasted text> but it is actually entered enveloped by ^[[200~ and ^[[201~ symbols.

ERROR: gcloud crashed (InvalidGrantError): (invalid_grant) Malformed auth code.

How to fix that?

Expected Behavior

Command works

Actual Behavior

Command fails

Originally created by @speller on GitHub (Jul 7, 2021). ### Windows Terminal version (or Windows build number) 1.8.1521.0, 10.0.21390.2025 ### Other Software _No response_ ### Steps to reproduce When I run the following command in Ubuntu 20 from under Windows Terminal: ``` docker run -ti --name gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk:alpine gcloud auth login ``` I'm getting the following input when pasting the key: ``` Go to the following link in your browser: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=<long URL> Enter verification code: ^[[200~<real pasted text>^[[201~ ``` The command fails to process this input. I'm pasting the `<real pasted text>` but it is actually entered enveloped by `^[[200~` and `^[[201~` symbols. ``` ERROR: gcloud crashed (InvalidGrantError): (invalid_grant) Malformed auth code. ``` How to fix that? ### Expected Behavior Command works ### Actual Behavior Command fails
claunia added the Needs-TriageNeeds-Tag-FixResolution-No-Repro labels 2026-01-31 04:09:36 +00:00
Author
Owner

@skyline75489 commented on GitHub (Jul 7, 2021):

Interesting report! This is caused by "bracketed paste mode" (see #395), which is only enabled after the shell/application deliberately asks the terminal to enable this feature.

For more context, what is the shell you're using?

@skyline75489 commented on GitHub (Jul 7, 2021): Interesting report! This is caused by "bracketed paste mode" (see #395), which is only enabled after the shell/application deliberately asks the terminal to enable this feature. For more context, what is the shell you're using?
Author
Owner

@speller commented on GitHub (Jul 7, 2021):

I started a new shell tab window and it worked as expected so I can not reproduce it now....
I'm using the bash shell but the script's shebang is #!/usr/bin/env sh. I tried to add printf "\e[?2004l" or set enable-bracketed-paste off to my script but it didn't help.

@speller commented on GitHub (Jul 7, 2021): I started a new shell tab window and it worked as expected so I can not reproduce it now.... I'm using the `bash` shell but the script's shebang is `#!/usr/bin/env sh`. I tried to add `printf "\e[?2004l"` or `set enable-bracketed-paste off` to my script but it didn't help.
Author
Owner

@zadjii-msft commented on GitHub (Jul 7, 2021):

skyline75489 is right, those characters are the bracketed paste sequences.

so I can not reproduce it now....

Well shucks. I'm gonna close this for now - if you run into a way to reliably reproduce this, feel free to comment here and we can reopen.

@zadjii-msft commented on GitHub (Jul 7, 2021): skyline75489 is right, those characters are the bracketed paste sequences. > so I can not reproduce it now.... Well shucks. I'm gonna close this for now - if you run into a way to reliably reproduce this, feel free to comment here and we can reopen.
Author
Owner

@yellowpattern commented on GitHub (Feb 13, 2023):

I am seeing this exact same issue.

@yellowpattern commented on GitHub (Feb 13, 2023): I am seeing this exact same issue.
Author
Owner

@ivsanro1 commented on GitHub (Mar 8, 2023):

One hacky workaround to disable bracketed paste in the current terminal (the one in which you'll be running the gcloud auth command) is to run:

printf '\e[?2004l'

And then the sequences ^[[200~ and ^[[201~ should not appear anymore when pasting

@ivsanro1 commented on GitHub (Mar 8, 2023): One hacky workaround to disable bracketed paste in the current terminal (the one in which you'll be running the gcloud auth command) is to run: ```bash printf '\e[?2004l' ``` And then the sequences `^[[200~` and `^[[201~` should not appear anymore when pasting
Author
Owner

@Artim96 commented on GitHub (Jul 30, 2023):

I'm surprised this couldn't be reproduced. This has been a problem for me since day one of using the Terminal. It doesn't happen when using e.g. PowerShell or CMD through it, but any Linux shell will do that, unless you e.g. paste the text into emacs or the sorts. It also doesn't matter if it's the local Debian WSL or any Linux system accessed through ssh. Using Ctrl+Shift+V instead of using Ctrl+V as some recommend doesn't help, as I don't use anything else. And going to each systems ~/.inputrc to enter "set enable-bracketed-paste off" isn't really an option and shouldn't be the solution, as it very much seems to be a fault of the Terminal app. Maybe @zadjii-msft can re-open this issue, as it's very much reproducible and should finally be fixes after so many years.

@Artim96 commented on GitHub (Jul 30, 2023): I'm surprised this couldn't be reproduced. This has been a problem for me since day one of using the Terminal. It doesn't happen when using e.g. PowerShell or CMD through it, but any Linux shell will do that, unless you e.g. paste the text into emacs or the sorts. It also doesn't matter if it's the local Debian WSL or any Linux system accessed through ssh. Using Ctrl+Shift+V instead of using Ctrl+V as some recommend doesn't help, as I don't use anything else. And going to each systems ~/.inputrc to enter "set enable-bracketed-paste off" isn't really an option and shouldn't be the solution, as it very much seems to be a fault of the Terminal app. Maybe @zadjii-msft can re-open this issue, as it's very much reproducible and should finally be fixes after so many years.
Author
Owner

@ersjim commented on GitHub (Nov 20, 2023):

For me it only happens when I ssh into another linux server from WSL.

@ersjim commented on GitHub (Nov 20, 2023): For me it only happens when I ssh into another linux server from WSL.
Author
Owner

@cgkantidis commented on GitHub (Feb 22, 2024):

I have the same issue when I paste with right click.
I'm only using the MS terminal to ssh into a linux machine so I'm not sure if it's exclusively there when in ssh, but it still happens.
When I paste, I see these characters getting appended to whatever was pasted 01~, but it doesn't happen always.

I never had this issue with Putty, so it must be an issue with MS terminal.

This issue should be re-opened.

@cgkantidis commented on GitHub (Feb 22, 2024): I have the same issue when I paste with right click. I'm only using the MS terminal to ssh into a linux machine so I'm not sure if it's exclusively there when in ssh, but it still happens. When I paste, I see these characters getting appended to whatever was pasted `01~`, but it doesn't happen always. I never had this issue with Putty, so it must be an issue with MS terminal. This issue should be re-opened.
Author
Owner

@bessone commented on GitHub (Nov 7, 2024):

From a few days the same thing as @christosg88 has happened to me, via terminal with PowerShell I open an ssh session on remote linux machines and the paste has this behavior.
But only for a couple of days, before it always worked. Has there been any update to terminal or SSH/Powershell?

@bessone commented on GitHub (Nov 7, 2024): From a few days the same thing as @christosg88 has happened to me, via terminal with PowerShell I open an ssh session on remote linux machines and the paste has this behavior. But only for a couple of days, before it always worked. Has there been any update to terminal or SSH/Powershell?
Author
Owner

@bessone commented on GitHub (Nov 7, 2024):

Small update: I tried in terminal with WSL and it works, so surely the problem is not with terminal, but with openssh of powershell.

@bessone commented on GitHub (Nov 7, 2024): Small update: I tried in terminal with WSL and it works, so surely the problem is not with terminal, but with openssh of powershell.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14413