Cannot Paste blocks of code into Windows Terminal

Good Morning Everyone,

My issue comes with how PowerShell is handling when I paste in text. If I open Powershell directly, it works as expected, allows me to paste in a block of text and execute. If I paste the same code into Windows Terminal, it wants to run every line individually. I’ve checked $PSVersionTable, and they are both running the same version of powershell. What am I missing here?

https://snipboard.io/BCWfiy.jpg - Snaggy Link to a screen shot of the issue

Thanks,

-Rob

But that’s the standard behaviour on all consoles except of the ISE. … at least it is this way here on all of my machines … :wink:

I wonder what I’ve changed in the past then that I can’t find now. Because PowerShell by itself does not have that behavior, it acts like I thought it would, I can paste an entire script in before it starts executing.

By windows “terminal” I assume you mean a command shell? That shell is NOT an interactive scripting shell. You will need to enter “powershell” in the command shell first to get the behavior you desire.

 

… hhhmmmm … quite … :wink:

https://github.com/Microsoft/Terminal#welcome-to-the-windows-terminal-console-and-command-line-repo

Understood, thanks Olaf :slight_smile:

Olaf is correct, that is the program that I am using.

Below is a screen shot of what I’m trying to explain. PowerShell is in blue. PowerShell in Windows Terminal is in Black, Notepad to the right with the simple write-host block of text.

As you can see, PowerShell stand alone pastes the entire block of text and then executes, where PowerShell in windows terminal wants to execute every line separately. In this example it doesn’t really matter, but if I’m pasting in something with 30-50 lines of code, it causes issues.

 

Oh I got it. In powershell console, hit control v to paste. But I have psreadline set to emacs mode, so that key gets rebound for me.

It should work in Windows Terminal too, unless your settings file binds control-v to something else. Psreadline has to control it. It looks like Vscode controls control-v as well.

OK, I will throw this out there, see where it lands. I have always use the right mouse to paste into a shell, be it powershell or a command shell. Right click in the shell and whatever is in the clipboard is copied. Have you tried that?

I already solved it.

And you solved it how? What did I miss? BTW, I see no screen shots.

I don’t see a fix either…
Tony, in powershell, ctrl-v, shift+insert both paste the text as a block. If I right click it wants to run line by line.

In Windows terminal, ctrl-v, shift+insert, and right click all want to run the text line by line.

Go into your windows terminal settings, and delete or comment out the binding for control+v.

For example. change

 { "command": "paste", "keys": "ctrl+v" },

to this, to comment it out.

// { "command": "paste", "keys": "ctrl+v" },

Strange that the settings it comes with isn’t as good as the default settings, and doesn’t have the themes.

JS, that worked like a charm. Thank you.[quote quote=226431]For example. change

<textarea class="ace_text-input" style="opacity: 0; height: 17.6px; width: 6.59775px; left: 44px; top: 0px;" spellcheck="false" wrap="off"></textarea>
1
{ "command": "paste", "keys": "ctrl+v" },
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
to this, to comment it out.
<textarea class="ace_text-input" style="opacity: 0; height: 17.6px; width: 6.59775px; left: 44px; top: 0px;" spellcheck="false" wrap="off"></textarea>
1
// { "command": "paste", "keys": "ctrl+v" },
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Strange that the settings it comes with isn’t as good as the default settings, and doesn’t have the themes.

[/quote]