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 undefAnd add the following line to your ~/.inputrc:
These modifications will unmap
lnext (literal next-character) and
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
konsole, or translation tables with
Useful commands for reference:
$ bind -p
$ stty -a
THANK YOU for this information. Why didn't I google this before?? :-)
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
Thanks!! is perfect.
But if I want to use Ctrl+C to copy???
use \C-c seems not work.
Thanks in advance
Thank you so much. This can help me a lot. :)
jlupbox: rxvt-cygwin (not the client or server variations that need Cygwin/X started to run right) copies by merely selecting the text. Just be careful how much you select: sometimes you can "trap" right back to your prompt (like right-hand carats or a dollar sign) which, if pasted without editing, will return a "Command not found" error in almost every shell.
Hey, it's better than nothing. rxvt-cygwin's a big-time compromise already. Just read the Cygwin mailing-list archives to see what I mean.
Anyone figured out how to pass this (ctrl-v for paste from clipboard) to scripts? It's still shift-insert on a "read" command execution in all of mine? Ctrl-V just reverts to its old binding (whatever that was) and most of the time will terminate a script (or your shell and terminal, worse still).
Thanks.. It works.. But, Cntl X won't work for cut.
Amazing thank you :)
Do you happen to know how to map the paste to ctrl-shift-v key? I have done my research, but shift is not a modifier key for readline. I wish there was something like xev where I do my keystroke and get the equivalent key (for readline, that is). Was there any file, reference, or program that helped you to figure things out?
Very cool, thanks for taking the time.
Thank you so much! This tip makes life worth living.
@John (comment #9) - I know it's been a while but since this comes out on top of my Google search results maybe it will help someone. I used sed -n l to find the keycode combination. I now have this in my .inputrc in my CygWin instance:
"\302\203": copy-to-clipboard "\302\226": paste-from-clipboard
It works. Sort of. For example, vim doesn't seem to like to paste with it but that may be a .vimrc change I need to research.
@Jeff Bower helped me greatly so I'm going to return the favor. Since we are now using Ctrl+Shift+v to paste, we can set up a mapping in vim like so
:imap <type ctrl+shift+v=""> <type ctrl+v=""><type ctrl+r="">*
on the command line it will look like
:imap <96> ^R*
. That's for insert mode. If you want it to work for command mode do a
for normal mode do an
If using Cygwin ('bash in windows'), click the Cygwin icon in the top left corner of the winoow (either mouse button should work), then select "Options" from the drop down, then select "Mouse" from the left Options menu, then 1) Tick "Copy on select" at the top, then 2) Tick "Paste" under the "Click Actions > Right Mouse Button". Click Save.
From now on, whatever you select in the Cygwin (bash) console (including the command prompt) will automatically be copied to the clipboard, and whenever you Right Click the Mouse cursor, it will paste it into the console following the last prompt.
This behaviour is similar to that found is tools such as PuTTY and SecureCRT.
BE CAREFUL IF YOU ARE LOGGED ONTO A PRODUCTION SERVER OR SYSTEM!!! ;)
The least troublesome way I have found is to enable copy on select (in Options... | Mouse), and the Ctl+Shift shortcuts (in Options.. | Keys). Then you can use Ctl-Shift-V to paste which is close enough to be bearable