Saltycrane logo

SaltyCrane Blog

Notes on Python, Django, and web development on Ubuntu Linux

    

How to paste in Cygwin bash using CTRL-V

I come from a Windows background where Cut/Copy/Paste are almost always CTRL+X/C/V respectively. I like this consistency, so adjusting to Cygwin's (or other *nix environments') use of SHIFT+INSERT or the middle mouse button for pasting in terminals is a little annoying. After a bit of googling, I found a mailing list thread that solved my problem.

This method uses a modification to readline's ~/.inputrc configuration file, so it should work in rxvt, xterm, or even the default cmd.exe shell. Here is what to do:

Add the following line to your ~/.bashrc:
stty lnext ^q stop undef start undef
And add the following line to your ~/.inputrc:
"\C-v": paste-from-clipboard

These modifications will unmap stty's lnext (literal next-character) and readline's quoted-insert settings which are normally mapped to CTRL-V. For more details, see this cygwin mailing list thread.

Note, this appears to be a Cygwin-specific solution. Linux users could use custom key bindings in gnome-terminal or konsole, or translation tables with xterm.


Useful commands for reference:
$ bind -p
$ stty -a

3 Comments


#1 Emma commented on 2009-05-13:

THANK YOU for this information. Why didn't I google this before?? :-)


#2 Silversleeves commented on 2009-12-24:

Fair warning for those who want to try Terminator.

The stty command for Cygwin brings up an error in terminator. Apparently there's an stty.exe that was hatched without one or the other of the commands in that string. Curiously enough, the Xterm-based terminals don't seem to have this problem.

Terminator supports ctrl-v paste all on its own [it should -- it requires the Cygwin/X java and ruby files to run...for that kind of disk cost it should also polish my shoes. :)] BZT


#3 jlupox commented on 2010-03-08:

Thanks!! is perfect.

But if I want to use Ctrl+C to copy???

use C-c seems not work.

Thanks in advance

Post a comment

Required
Required, but not displayed
Optional

Format using Markdown. (No HTML.)
  • Code blocks: prefix each line by at least 4 spaces or 1 tab (and a blank line before and after)
  • Code span: surround with backticks
  • Blockquotes: prefix lines to be quoted with >
  • Links: <URL>
  • Links w/ description: [description](URL)
Created with Django | Hosted by Slicehost