Unable to copy/paste in MinGW shell

I just installed MinGW on Windows and I'm unable to copy/paste as I am used to on Linux or even PuTTY. What is the trick for copying and pasting text (e.g. from chrome) into MinGW shell?


Solution 1:

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.

Solution 2:

[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

Solution 3:

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

Solution 4:

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.

Solution 5:

@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