Is there a way to copy PowerShell buffer using one of Windows Terminal actions? #15349
-
I am in a bit of a dilemma here, I will explain myself first. In Windows Terminal I only ever use PowerShell (7.3) and in my PowerShell profile I have the following:
I am trying to get Copy to clipboard on the terminal to conform to way it works everywhere else on Windows: Only copy to clipboard IF there is a selection I cant seem to find a way around: How Copy to Clipboard is handled on the terminal. In Windows Terminal (More specifically, PowerShell) this is not so. The following is a recording from a terminal window, when I copy the text, the selection is discarded: In this recording from Notepad, when I copy the selection to the clipboard, the selection is maintained: I would like Terminal/PowerShell to behave exactly like Notepad From this article Selecting text in Windows Terminal part of Windows Terminals documentation:
This would be a decent solution (I can assign a keyboard key to simulate a right click) but the above does not apply to the buffer (I mean, the text currently being typed) only to the terminals previous output. On this page Clipboard integration commands | Windows Terminal Actions
"This copies the selected terminal content to your clipboard" I think "terminal content" is meant as the terminal output, NOT the buffer. Is there a way to get the VSCode by default, has similar behaviour, but offers a means to disable it:
I am asking for a specific terminal method because looking at the all the PSReadLine class methods, no solution is provided for just performing conventional "copy to clipboard", these are the only two copy methods available:
Thanks for any help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
Here's a trick: the terminal doesn't actually know the difference between "output" and "input" in the buffer 😉
So that's me using Windows Terminal's built-in ctrl+c "Copy" action. If there's a selection, it'll copy and dismiss the selection. If there's no selection, it'll just send a
^C
to the connected client app.