Cut and paste with Rxvt

A while back I posted about using Rxvt with Cygwin.  As I mentioned then, using Rxvt instead of the default Cygwin shell solves a number of usability problems with the Cygwin shell, and gives you a much more comfortable, unixy shell environment.

But one thing that can be tricky about Rxvt is it’s cut and paste behaviour, which is quite a bit different than most Windows users are used to.  You can’t use the Windows standard Control-C and Control-V keystrokes to cut from and paste to Rxvt.  So what do you do?

Like many unix apps, Rxvt automatically copies anything you highlight with the mouse to the clipboard. Click and drag across a section of the Rxvt window with your mouse to highlight the text you want and presto! it’s on the clipboard.  There are also a couple of mouse/clipboard shortcuts in Rxvt: doubleclicking in the Rxvt window will highlight the word under the mouse cursor and tripleclicking will highlight the entire line.

The tricky part is pasting into Rxvt.  Instead of using Control-V, use Shift-Left Mouse click.   Odd isn’t it?  But trust me, you’ll get used to it.

I’ve seen a couple of posts on the net about editing .inputrc to re-map the clipboard paste function to Control-V, but I’ve never been able to get it to work quite right.   If anyone out there has figured it out, I’d love it if you could help me.  Please email me or post in the comment section below.

Advertisements

16 thoughts on “Cut and paste with Rxvt

  1. Anyone know how to change the default word-highlighting behavior of rxvt? In other words, when you double-click on a word it currently highlights that word AND any surrounding special characters. For example, instead of highlighting a part of a path when double-clicking on part of the path, it highlights the whole path. (Note that I’m not accidentally triple-clicking. I just need it to only highlight the word on which I double-click.)

    Anyone know how to change this?

  2. Using your middle mouse button will also paste, same as on X in Linux. I didn’t know about Shift-Left Mouse click.

  3. This slight modification of the PERL module author’s example allows for a neat backticking. See some cool bash one-liner? Copy it and type: `clipbd`

    If you’re ambitious, try extending it so you can send STDIN to the clipboard!

    $ cat /bin/clipbd
    #! /bin/perl
    use Win32::Clipboard;
    $CLIP = Win32::Clipboard();
    print $CLIP->Get();

  4. The line in my .inputrc that handles pasting from clipboard is

    “\C-v”: paste-from-clipboard

    I think I found it here

    http://infrablue.tripod.com/cygwin.html
    (more than halfway down-page, after the short paragraph that starts “Finally, to your .inputrc…”)

    As for copying, ctrl-c seems to work, though in Cygwin’s rxvt — which is the one I use — it also generates the conventional Unix/Linux ‘break’ line and gives me my standard prompt. Nevertheless, I’ve seldom had problems pasting whatever was copied from a term window using ctrl-c. I suppose if you were to add it to .inputrc, you’d use the same syntax as I found on the Tripod page, eg: “\C-c” copy from clipboard (but in so doing you’d lose the break/cancel effect that’s too often necessary to retain, imo).

    Hope this was helpful.

    BZT

  5. I ran across this while googling for something else. I see the last response was from over a year ago, but what the heck.

    Rather than the (admittedly quite cool) Perl script posted by Al Leitch, you can just use the cygwin “getclip” and “putclip” commands. There don’t seem to be any man pages, but both print usage message with the “–help” option.

  6. rxvt-cygwin now copies as soon as some text is selected. It can be on the current line you’re on or any previous one back to the beginning of the buffer (safest to limit yourself to the top of the terminal window, methinks). It will paste right back to a prompt from anything either still selected or de-selected. (Genius. Wish GNOME-Terminal and Konsole worked like that.)
    Now if they could just get it to stop tiling background images, we’d be set.

    BZT

  7. A few comments:

    The “select” + middle button click in X11 is actually analogous to the windows drag&drop and not copy&paste. There is also a copy&paste in X11.

    Strangely i can’t make rxvt work in X11 with the .inputrc trick 😦 The right click paste works there — not clear if it is from which clipboard it gets though — but I’m still trying to find a way to copy&paste without having to go to the mouse and causing more pain to my wrist …

    thx!

  8. Thanks for this info!

    I’ve always despised using the wheel button for pasting, preferring instead to assign the paste operation to left click; for the following reasons..

    + Wheel buttons usually require more downward pressure than the right and left buttons. I find myself constantly distracted by depressing the wheel and wondering if I’m actually going to get the text pasted or not, or, worse, if I press too hard I get double or triple pasting.

    + While pressing the wheel, it invariably engages the scroll operation, moving my window’s focus. Though it does paste the text where I desire it to appear, it also destroys my concentration on the work I am ostensibly trying to accomplish, by forcing me to visually rescan the page for where I left off.

    + The required pressure varies *greatly* from one mouse wheel to the next – just when you get used to your wheel at work it is time to reprogram your fingers to use the right amount of pressure with the wheel your have at home.

    + Having to move a finger off of the right or left button and onto the wheel can require (depending on the mouse) a clumsy and awkward finger movement.

    I have been in search of a way to assign Paste to Right-Click in rxvt and/or mrxvt – both in a cygwin installation.

    I have used this for many years with putty, but putty is for working on a remote system.

    So, if you or someone else using cygwin knows how to reassign Right-Click in rxvt/mrxvt to perform a Paste operation – PLEASE advise!!!

    I’m now resorting to the joy of sifting through the source code and figuring out how to add the capability. But that might be beyond my coding skill set 😦

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s