在 Windows 上的 Ubuntu 上复制粘贴到 Bash
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38832230/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Copy Paste in Bash on Ubuntu on Windows
提问by Ghassan Zein
How to execute a copy paste operation from Windows 10 to the Bash on Ubuntu on Windows environment?
如何在 Windows 环境下的 Ubuntu 上执行从 Windows 10 到 Bash 的复制粘贴操作?
I tried the following:
我尝试了以下方法:
- ctrl+ shift+ v
- right click to paste
- ctrl+ shift+v
- 右键单击以粘贴
Any suggestions?
有什么建议?
采纳答案by chipit24
Update 2019/04/16:It seems copy/paste is now officially supported in Windows build >= 17643. Take a look at Rich Turner's answer. This can be enabled through the same settings menu described below by clicking the checkbox next to "Use Ctrl+Shift+C/V as Copy/Paste".
2019 年 4 月 16 日更新:Windows build >= 17643 现在似乎正式支持复制/粘贴。看看Rich Turner 的回答。这可以通过下面描述的相同设置菜单启用,方法是单击“使用 Ctrl+Shift+C/V 作为复制/粘贴”旁边的复选框。
Another solution would be to enable "QuickEdit Mode" and then you can paste by right-clicking in the terminal.
另一种解决方案是启用“快速编辑模式”,然后您可以通过右键单击终端进行粘贴。
To enable QuickEdit Mode, right-click on the toolbar (or simply click on the icon in the upper left corner), select Properties, and in the the Options tab, click the checkbox next to QuickEdit Mode.
要启用快速编辑模式,请右键单击工具栏(或只需单击左上角的图标),选择属性,然后在选项选项卡中,单击快速编辑模式旁边的复选框。
With this mode enabled, you can also copy text in the terminal by clicking and dragging. Once a selection is made, you can press Enter or right-click to copy.
启用此模式后,您还可以通过单击和拖动来复制终端中的文本。做出选择后,您可以按 Enter 或右键单击进行复制。
回答by jaredlt
回答by α?sнιη
Ok, it's developed finally and now you are able to use Ctrl+Shift+C/Vto Copy/Paste as of Windows 10 Insider build #17643.
好的,它终于开发出来了,现在你可以使用Ctrl+ Shift+ C/V来复制/粘贴 Windows 10 Insider build #17643。
You'll need to enable the "Use Ctrl+Shift+C/V as Copy/Paste"option in the Console "Options" properties page:
您需要在控制台“选项”属性页面中启用“使用 Ctrl+Shift+C/V 作为复制/粘贴”选项:
referenced in blogs.msdn.microsoft.com/
回答by Rich Turner
At long last, we're excited to announce that we FINALLY implemented copy and paste support for Linux/WSL instances in Windows Consolevia CTRL+ SHIFT+ [C|V]!
最后,我们很高兴地宣布,我们最终通过+ + [ |在 Windows 控制台中实现了对 Linux/WSL 实例的复制和粘贴支持。]!CTRLSHIFTCV
You can enable/disable this feature in case you find a keyboard collision with a command-line app, but this should start working when you install and run any Win10 builds >= 17643.
如果您发现键盘与命令行应用程序发生冲突,您可以启用/禁用此功能,但是当您安装和运行任何 Win10 版本 >= 17643 时,这应该开始工作。
Thanks for your patience while we re-engineered Console's internals to allow this feature to work :)
感谢您在我们重新设计 Console 的内部结构以允许此功能运行时的耐心等待 :)
回答by Fernando Rodriguez
You can use AutoHotkey (third party application), the command below is good with plain alphanumeric text, however some other characters like =^"%#!
are mistyped in console like bash or cmd. (In any non-console window this command works fine with all characters.)
您可以使用 AutoHotkey(第三方应用程序),下面的命令适用于纯字母数字文本,但是其他一些字符=^"%#!
在控制台中输入错误,如 bash 或 cmd。(在任何非控制台窗口中,此命令适用于所有字符。)
^+v::SendRaw %clipboard%
回答by cryogenyx
Edit / Paste from the title bar's context menu (until they fix the control key shortcuts)
从标题栏的上下文菜单中编辑/粘贴(直到他们修复控制键快捷键)
回答by Ilhicas
Like it has been written before:
就像之前写过的:
- Right Click on Bash on Ubuntu on Windows Icon if you have it on a Task Bar Shortcut Icon
- Click on Properties
- Select Options Tab on the Properties Window
- Check the QuickEditMode option
- Click Apply
- 如果您在任务栏快捷方式图标上有它,请右键单击 Windows 图标上的 Ubuntu 上的 Bash
- 点击属性
- 在属性窗口中选择选项选项卡
- 检查 QuickEditMode 选项
- 点击应用
Now you are able to open a new Bash Terminal and just use Right-Click to paste
现在您可以打开一个新的 Bash 终端并使用右键单击粘贴
In order to be able to copy from Terminal, Just use CTRL+M and this will enable you to select and copy selected Text.
为了能够从终端复制,只需使用 CTRL+M,这将使您能够选择和复制选定的文本。
回答by Stuart Brock
As others have said, there is now an option for Ctrl+Shf+V
for paste in Windows 10 Insider build #17643.
正如其他人所说,现在可以选择Ctrl+Shf+V
在 Windows 10 Insider build #17643 中进行粘贴。
Unfortunately this isn't in my muscle memory and as a user of TTY terminals I'd like to use Shf+Ins
as I do on all the Linux boxes I connect to.
不幸的是,这不是我的肌肉记忆,作为 TTY 终端的用户,我想像Shf+Ins
在我连接到的所有 Linux 机器上一样使用。
This is possible on Windows 10 if you install ConEmuwhich wraps the terminal in a new GUI and allows Shf+Ins
for paste. It also allows you to tweak the behaviour in the Properties.
如果您安装ConEmu,它将终端包装在新的 GUI 中并允许Shf+Ins
粘贴,则这在 Windows 10 上是可能的。它还允许您调整属性中的行为。
Shf+Ins
works out of the box. I can't remember if you need to configure bash as one of the shells it uses but if you do, here is the task properties to add it:
Shf+Ins
开箱即用。我不记得您是否需要将 bash 配置为它使用的 shell 之一,但是如果您这样做了,这里是添加它的任务属性:
Also allows tabbed Consoles (including different types, cmd.exe
, powershell
etc). I've been using this since early Windows 7 and in those days it made the command line on Windows usable!
还允许选项卡式控制台(包括不同类型cmd.exe
、powershell
等)。我从早期的 Windows 7 开始就一直在使用它,在那些日子里,它使 Windows 上的命令行可用!
回答by Jon49
For pasting into Vim in the terminal (bash on ubuntu on windows):
在终端中粘贴到 Vim(在 Windows 上的 ubuntu 上使用 bash):
export DISPLAY=localhost:0.0
export DISPLAY=localhost:0.0
Not sure how to copy from Vim though :-(
不知道如何从 Vim 复制 :-(
回答by Gubatron
Alternate solution over here, my windows home version Windows Subsystem Linux terminal doesn't have the property to use Shift+Ctrl (C|V)
此处的替代解决方案,我的 Windows 家庭版 Windows 子系统 Linux 终端没有使用 Shift+Ctrl (C|V) 的属性
Use an actual linux terminal]1
使用实际的 linux 终端] 1
- Install an X-server in Windows (like X-Ming)
sudo apt install <your_favorite_terminal>
export DISPLAY=:0
- fire your terminal app, I tested with xfce4-terminal and gnome-terminal
- 在 Windows 中安装 X 服务器(如 X-Ming)
sudo apt install <your_favorite_terminal>
export DISPLAY=:0
- 启动你的终端应用程序,我用 xfce4-terminal 和 gnome-terminal 进行了测试