Powershell: Copy & paste is not working properly on Windows 10

Created on 19 Jul 2017  路  27Comments  路  Source: PowerShell/PowerShell

I need to right click to paste which everything but aligned with everything else. On Mac's terminal you can just "Cmd + V" everywhere.

Issue-Question OS-Windows Resolution-Answered WG-Interactive-Console

Most helpful comment

Run Install-Module PSReadLine -AllowPrerelease -AllowClobber -Force and restart, you'll have 2.0.0-beta1 which fixes most of the issues people have had.

All 27 comments

Good find.

It looks like a PSReadLine issue.

You can verify this by running Remove-Module PSReadLine in your session (which is obviously not a real solution, as it disables all PSReadLine features), at which point the W10 console windows' native selection and copy & paste features start working.

I suggest posting an issue there - correct, @iSazonov?

Could you please test on Linux too?

@iSazonov:

Linux terminals typically use 鈱冣嚙C and 鈱冣嚙V rather than 鈱僀 and 鈱僔.

I can confirm that 鈱冣嚙C and 鈱冣嚙V work as expected in the default terminal on Ubuntu 16.04.

@mklement0 Thanks for the test!

After executing Remove-Module PSReadLine Ctrl + V works fine again on Windows 10 (Creators Update)/PS6beta4.

@lzybkr Could you please comment the Issue?

Another, slightly unrelated question:

When I launch "Ubuntu Bash" in PS and want to use Ctrl + V as well, I get ^V -- only right-click works. With https://conemu.github.io/ it works fine but I do not want to use it because if its preferences bloat.

@loxal: I don't think that's a PowerShell problem; bash.exe is in control of keyboard handling, and you get the same (broken) behavior whether you invoke it from PowerShell or directly, via the official shortcut.

PSReadline depends on winforms for clipboard support, but winforms is not in .Net Core. We likely need to extract the clipboard p/invoke code from winforms to get copy/paste support in PSReadline, but that still won't help on non-Windows platforms that might not support a clipboard at all.

If it work without PSReadline why we need the clipboard p/invoke ?

Cooked mode command line editing (conhost) supports basic selection and clipboard, but isn't extensible, so PSReadline uses raw mode and loses some things like clipboard support.

Is there no way to passthrough for clipboard support?

Not really, there could be some horrible hack, but no clean way.

@lzybkr Thanks for clarify!

Unix doesn't seem to have a common clipboard 馃槙. I guess we have to fix at least Windows.

Any movement on this? Would love to be able to get my ctrl + v back :)

+1 with @aarsan

This works in Windows PowerShell without doing "remove-module psreadline", but not in PSCore 6.0.0.
In PSCore 6.0.0, only works if I do the "remove-module psreadline".

:)

Run Install-Module PSReadLine -AllowPrerelease -AllowClobber -Force and restart, you'll have 2.0.0-beta1 which fixes most of the issues people have had.

Awesome. Worked, but I had to add the -SkipPublisherCheck argument. Thanks!

I think we can close the Issue - with PSReadline 2.0.0 we got Ctrl-V and Ctrl-C on Windows back.

In which version of PowerShell Core will PSReadline 2.0.0 land?

@Hrxn - hopefully 6.1

Any progress on this? Still not working with 6.0.2 / PSReadLine 1.2

You can install PSReadLine 2.0.0-beta1. Beta2 will hopefully ship with the next preview of 6.1.

@lzybkr:

Thanks for fixing most of the issues in v2, on all platforms.

The one thing that still doesn't seem to work on _Unix_ platforms is copying _keyboard-based_ selections to the clipboard.

What would be required to support that?

@mklement0 - I haven't really looked into clipboard support for non-WIndows - I'd sort of assumed the only viable approach was to use an external utility like pbcopy or xclip or whatever the tool might be called.

@lzybkr:

Indeed: on macOS it is pbcopy, on freedesktop.org-compliant Linux distros (X11-based desktops) it is the xclip utility, which, unfortunately, isn't preinstalled.

My ClipboardText module provides a PS wrapper around these (including around clip.exe on Windows), if it helps. (It only _warns_ about a missing xclip and provides installation _hints_, however).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rkeithhill picture rkeithhill  路  3Comments

SteveL-MSFT picture SteveL-MSFT  路  3Comments

JohnLBevan picture JohnLBevan  路  3Comments

aragula12 picture aragula12  路  3Comments

garegin16 picture garegin16  路  3Comments