无法复制/粘贴 MinGW shell

我刚刚在 Windows 上安装了 MinGW,我无法像在 Linux 甚至 PuTTY 上那样复制/粘贴。复制和粘贴文本(例如从 chrome)到 MinGW shell 的技巧是什么?

47399 次浏览

Right-click on the title bar of the command window and select 'Properties', then on the 'Options' tab tick the box for the 'QuickEdit mode', then click 'Ok'.

After that you can paste text from the clipboard using the right mouse-button, highlight text while holding down the left mouse-button and copy selected text using the ENTER key.

This procedure works on Windows 7/8, not Windows 10.

@mrt's solution above is permanent. Here's a quicker way for any 16bit prompt in Windows:

COPY

Click on the icon on the top left > Edit > Mark, select the text and then right-click

PASTE

Similar process as above (use Edit > Paste) OR just press INSERT key

I ran into this problem and above solutions didn't work for Windows 10. This is because there is no Properties on the Menu. However with the above solution content, I was able to resolve it for Windows 10 as follows: Right click the icon on the top left hand corner of MINGW64: Select Options Now Select keys On the right hand you will find Shortcuts If not thicked, thick Copy and Paste Now always remeber the instruction given to copy & paste as follows: Copy: Ctrl+ Ins (insert) i.e. To copy on MINGW, only highlight whatever you want to copy, then press Ctrl Insert keys Paste; Shift+ Ins (insert) i.e. To paste, place your cursor where you want paste. Then press Shift Insert keys

Now select Mouse On the right hand you will find Mouse functions If not thicked, thick Copy on select and Copy as rich text For mouse button, thick Right mouse paste Note: to copy on MINGW, simply highlight whatever you want to copy. Then place your cursor where you want paste. then click the mouse right button. Now click save or Apply then Save. I have tried these and everything is fine. Note that you can also copy from any other source and use paste to MINGW using the paste instructions above.

Win7 running MINGW64 (mintty 2.7.3) which came with the current version of Git Bash 2.1.3.0 from date of this comment.

Right click title bar of shell > Mouse > under Click actions > Right mouse button > select the Paste radio button.

However, I was surprised to find this didn't allow me to paste using my right click on my mouse.

I had to also select Application mouse mode > Default click target > Window

After changing both settings I was able to paste.

So it seems the new shell that comes with the current version of Git bash has new features. It also seems to be a bit buggy. For instance running an an executable via cli (e.g. php -version results in empty output and forces me to restart the shell). Waiting for a new update, hopefully which will fix this.

[Alternative] For MINGW64 (mintty 2.7.9) terminal in Windows 10, you can enable "Ctrl+Shift+letter shortcuts" to perform copy with (Ctrl+Shift+c) and paste with (Ctrl+Shift+v).

To enable the feature:

  1. right-click command window
  2. Click on 'Keys'
  3. Check the box for 'Ctrl+Shift+letter shortcuts'

When you vi/vim into a file:

  • To copy: highlight the portion you want and click 'y'
  • To cut: highlight the portion you want and click 'd'
  • To paste: Ctrl+Shift+v

This mintty bug CTRL + C & CTRL + V copy paste addresses the issue. It allows normal Control-C, Control-V copy and pasting, but at the expense of changing other control characters. So to stop a process running you need Control-Shift-C, to interrupt it you would need Control-Shift-Z and to send an EOT you need Control-Shift-D. You may find the advantage of windows copy and paste outwights the disadvantages.

The behavior needs a flag to be set in the .minttyrc file. WHich should look like

CtrlShiftShortcuts=yes
CtrlExchangeShift=yes

I prefer running the MSYS2 shell inside Console2 or ConsoleZ. This allows setting right-lick for paste and copy on select, just like in Linux and PuTTY. It also combines multiple MSYS2 shells in one window with tabs.

Windows 11 also has a similar terminal program now, but I haven't tried it yet with MSYS2...