Welcome › Forums › General PowerShell Q&A › Cannot Paste blocks of code into Windows Terminal
- This topic has 14 replies, 4 voices, and was last updated 8 months, 3 weeks ago by
Participant.
-
AuthorPosts
-
-
May 6, 2020 at 1:48 pm #226002
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
-
May 6, 2020 at 2:37 pm #226041
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 … 😉
-
May 6, 2020 at 2:38 pm #226044
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.
-
May 6, 2020 at 4:54 pm #226092
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.
-
May 6, 2020 at 5:03 pm #226095
By windows “terminal” I assume you mean a command shell?
….. hhhmmmm … quite … 😉
https://github.com/Microsoft/Terminal#welcome-to-the-windows-terminal-console-and-command-line-repo
-
May 6, 2020 at 5:10 pm #226098
Understood, thanks Olaf 🙂
-
May 6, 2020 at 7:34 pm #226137
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.
-
May 6, 2020 at 8:13 pm #226149
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.
-
May 6, 2020 at 8:51 pm #226182
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?
-
May 6, 2020 at 8:53 pm #226185
I already solved it.
-
May 6, 2020 at 10:06 pm #226212
And you solved it how? What did I miss? BTW, I see no screen shots.
-
May 6, 2020 at 10:26 pm #226215
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.
-
May 6, 2020 at 11:01 pm #226227
-
-
May 7, 2020 at 2:03 pm #226431
For example. change
PowerShell1{ "command": "paste", "keys": "ctrl+v" },to this, to comment it out.
PowerShell1// { "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.
-
This reply was modified 8 months, 3 weeks ago by
js.
-
This reply was modified 8 months, 3 weeks ago by
-
May 7, 2020 at 8:09 pm #226515
JS, that worked like a charm. Thank you.
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” },XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXto 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” },XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXStrange that the settings it comes with isn’t as good as the default settings, and doesn’t have the themes.
-
-
AuthorPosts
- The topic ‘Cannot Paste blocks of code into Windows Terminal’ is closed to new replies.