LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   rxvt-unicode hacking (https://www.linuxquestions.org/questions/slackware-14/rxvt-unicode-hacking-800818/)

mkoco 04-08-2010 11:29 AM

rxvt-unicode hacking
 
For any command-line junkies who favor rxvt-unicode, after years of struggle, here are a couple of things that changed my life:

256-color support and clickable URLs:
http://heipei.net/2009/01/04/rxvt-un...ickable-links/

Disable horizontal scroll mode, i.e. make long commands word-wrap in rxvt-unicode:
http://lists.freebsd.org/pipermail/f...er/026337.html
[Solved by adding an entry for urxvt in /etc/termcap]


Some other useful resources for using the full power of 256 colors ! :
http://graypine.com/data/colorstuff.tar.gz
Include is:
256color.pl - displays all colors in a grid
colortest - displays color, hex name, decimal name

Now truly rxvt-unicode is the ultimate, since xterm (afaik) doesn't have transparency OR click-able links.

Very happy slacker.

botnet 04-08-2010 01:51 PM

now if you can get copy/paste to work between urxvt and X applications, i will switch from mrxvt

dive 04-08-2010 04:23 PM

Quote:

Originally Posted by botnet (Post 3928870)
now if you can get copy/paste to work between urxvt and X applications, i will switch from mrxvt

Try postallite clip manager. It's on slackbuilds.org.

T3slider 04-08-2010 05:47 PM

Quote:

Originally Posted by botnet (Post 3928870)
now if you can get copy/paste to work between urxvt and X applications, i will switch from mrxvt

From here:

Code:

#! /usr/bin/perl

sub on_sel_grab {
    my $query=quotemeta $_[0]->selection;
    $query=~ s/\n/\\n/g;
    $query=~ s/\r/\\r/g;
    system( "echo -en " . $query . " | xsel -i -b -p" );
}

'Tis what I use, and it works well. Note that you need xsel for that to work. You could probably modify it for xclip as well.

botnet 04-08-2010 10:07 PM

awesome
that works perfectly

thanks

anyway to enable paste into urxvt?

edit: shift+insert does this, sort of.

usually not though,

tried parcellite and autocutsel, same issue, pasting from urxvt is fine, pasting into urxvt does not work as well

T3slider 04-08-2010 10:49 PM

Quote:

Originally Posted by botnet (Post 3929369)
awesome
that works perfectly

thanks

anyway to enable paste into urxvt?

edit: shift+insert does this, sort of.

usually not though,

tried parcellite and autocutsel, same issue, pasting from urxvt is fine, pasting into urxvt does not work as well

The problem is that the x clipboard uses three selections, not just one. The script above *always* operates on the primary selection. Pasting into urxvt with shift+insert also assumes the primary selection as well. You can try middle-clicking if it doesn't work properly, or run a clipboard manager that can push the other selections into the primary selection.

Sadly the clipboard situation in X/Linux is very messy, with applications choosing to use different selections for no good reason. Though this allows you to maintain multiple selections, unlike in Windows, it makes using the clipboard very tedious. I still think the best solution would be to have only a primary selection while being able to use clipboard managers that store the clipboard history allowing easy switching between selections. But what do I know, I am an end-user and the adoption of the various clipboards into all kinds of Linux applications is too ubiquitous to change at this stage.

botnet 04-09-2010 12:36 AM

i am currently using mrxvt

Mrxvt.macro.Shift+Alt+V: Paste CLIPBOARD
Mrxvt.macro.Shift+Alt+C: Exec !/usr/bin/xclip -o | /usr/bin/xclip -selection clipboard

these lines allow copy/paste between all applications i have come across

sadly, mrxvt has no unicode support

T3slider 04-09-2010 12:54 AM

Quote:

Originally Posted by botnet (Post 3929474)
i am currently using mrxvt

Mrxvt.macro.Shift+Alt+V: Paste CLIPBOARD
Mrxvt.macro.Shift+Alt+C: Exec !/usr/bin/xclip -o | /usr/bin/xclip -selection clipboard

these lines allow copy/paste between all applications i have come across

sadly, mrxvt has no unicode support

You could do the equivalent with your .Xdefaults file.
Code:

!urxvt.keysym.M-S-v: command:/usr/bin/xclip -selection clipboard -o
To paste, for example. That is untested so it may be incorrect but `man xclip` and `man urxvt` have information for you (search for keysym in urxvt's man page).

[edit] If you want to operate on the clipboard when you copy, you can just change the previous script to use the clipboard instead of the primary selection. Of course xclip would work as well. [/edit]

dive 04-09-2010 06:30 AM

Quote:

Originally Posted by botnet (Post 3929474)
sadly, mrxvt has no unicode support

I believe someone is working on unicode. Maybe the mailing list will give more info on progress. I did try it out but most other functions weren't working.

mkoco 04-09-2010 10:11 AM

Well, not quite great. This build of rxvt-unicode works well with my newer machines, but is slow with my older ones. I haven't tested it anything else but xmonad, but there is a lot of lag when doing any kind of dynamic resizing/opening of new terminal windows with the 256-color urxvt build.

Edit: Using this script as per your link T3Slider, copy and post works like charm!

Code:

#! /usr/bin/perl

sub on_sel_grab {
    my $query = $_[0]->selection;
    open (my $pipe,'|-','xsel -ibp') or die;
    print $pipe $query;
    close $pipe;
}


mkoco 04-09-2010 06:43 PM

The perl script doesn't cover copying text out of vim running into a terminal window, but the following covers that.

Added this line to my ~/.vimrc:
Code:

vmap <C-c> y:call system("xclip -i -selection clipboard", getreg("\""))<CR>:call system("xclip -i", getreg("\""))<CR>
and copy using C-c.

From: http://vim.wikia.com/wiki/In_line_co...stem_clipboard

botnet 04-10-2010 02:45 AM

okay, this is driving me mad

i can copy out of urxvt into, say firefox for example, using the script posted by t3slider, which, unless i am mistaken, replaces the clipboard contents with the primary buffer every time i highlight something in urxvt

i can paste into a new urxvt from firefox using "xsel -x; xsel -o -b | xsel -i; xdotool click 2; xsel -x" as a keybinding in xbindkeys

however, if i highlight something in urxvt, the above keybinding stops working, or rather, continues to only paste what was highlighted, and ignores any subsequent additions to the clipboard (the clipboard will still work normally outside of urxvt)


i simply want both the primary buffer and the X clipboard to always contain the same text, that being, whichever is newest, e.g. highlighted text in urxvt will be available from both, then if i ctrl+C some text in firefox, that text will be in both, and so on.

autocutsel claims to do this, but isn't
parcellite, likewise



(posting this here in hopes someone reads and figures out a solution before i am able to or angrily quit computers)

i did try writing a perl extension, but it either does nothing, or pastes the clipboard content into the parent terminal on launch, depending on how badly i have written it with each edit

catkin 06-09-2010 09:53 AM

Did you ever solve this, botnet? I'm also migrating from mrxvt to urxvt for unicode support (and was very happy with the mrxvt Ctrl+Shift+C or V macros you posted).

First problem, using the SlackBuild urxvt 9.07 on Slackware 13.1 is that the URxvt.keysym.M-S-c: command:<whatever> definition does not seem to work; on pressing Ctrl+Shift a yellow box with "ISO 14755 mode" is displayed after which pressing "c" displays a yellow box with:
Code:

c = □
00000080 = fg 0 bg 1
built-in support font

As an alternative, I tried the variation on the solution given by T3slider in this thread (both listed here) which, AIUI, automatically copies any text selected in urxvt to both X's PRIMARY and CLIPBOARD buffers. Having xclip but not xsel, I modified it like this which copies the selection only to te secondary a.k.a CLIPBOARD bufer but that's OK for me
Code:

#! /usr/bin/perl

sub on_sel_grab {
    my $query = $_[0]->selection;
    open (my $pipe,'|-','/usr/bin/xclip -in -selection secondary') or die;
    print $pipe $query;
    close $pipe;

Testing by starting urxvt, selecting text by positioning the mouse, left button press-and-hold, drag to select then switch to GUI text editor (Mousepad) and Ctrl+V to paste did nothing.

I don't know enough about how urxvt works or perl to even find if the perl script is being run.

BTW, I had no success putting urxvt resource definitions in ~/.Xdefaults but they are effective in ~/.Xresources. :scratch:

For testing changes to the various config files (/etc/termcap, /etc/inputrc and ~/.Xresources) I do not know what is necessary to fully re-initialise. xrdb -merge /home/c/.Xresources mostly works but does not undo some changes. Logging off and back on does some re-initialisation but there have been some experimental mistakes which seem to have required a reboot to re-initialise -- feels like Windows over again!

During experimentation, some error messages were usefully made visible by starting urxvt from a terminal rather than via a launcher -- such as syntactically incorrect entries in ~/.Xresources which made urxvt abort.

T3slider 06-09-2010 11:39 AM

Quote:

Originally Posted by catkin (Post 3997910)
First problem, using the SlackBuild urxvt 9.07 on Slackware 13.1 is that the URxvt.keysym.M-S-c: command:<whatever> definition does not seem to work; on pressing Ctrl+Shift a yellow box with "ISO 14755 mode" is displayed after which pressing "c" displays a yellow box with:
Code:

c = □
00000080 = fg 0 bg 1
built-in support font


Ah yes, I forgot about that. Ctrl+Shift is the key combo set for unicode entry in urxvt. I never use it and I haven't used any key combinations that overlap so I had forgotten about it. See "ISO 14755 SUPPORT" in `man urxvt` for more information. I'm not sure if you can rebind that or not, so you may be forced to use a different key combo (not involving Ctrl+Shift) for your binds...
Quote:

Originally Posted by catkin (Post 3997910)
As an alternative, I tried the variation on the solution given by T3slider in this thread (both listed here) which, AIUI, automatically copies any text selected in urxvt to both X's PRIMARY and CLIPBOARD buffers. Having xclip but not xsel, I modified it like this which copies the selection only to te secondary a.k.a CLIPBOARD bufer but that's OK for me
Code:

#! /usr/bin/perl

sub on_sel_grab {
    my $query = $_[0]->selection;
    open (my $pipe,'|-','/usr/bin/xclip -in -selection secondary') or die;
    print $pipe $query;
    close $pipe;

Testing by starting urxvt, selecting text by positioning the mouse, left button press-and-hold, drag to select then switch to GUI text editor (Mousepad) and Ctrl+V to paste did nothing.

I don't know enough about how urxvt works or perl to even find if the perl script is being run.

BTW, I had no success putting urxvt resource definitions in ~/.Xdefaults but they are effective in ~/.Xresources. :scratch:

For testing changes to the various config files (/etc/termcap, /etc/inputrc and ~/.Xresources) I do not know what is necessary to fully re-initialise. xrdb -merge /home/c/.Xresources mostly works but does not undo some changes. Logging off and back on does some re-initialisation but there have been some experimental mistakes which seem to have required a reboot to re-initialise -- feels like Windows over again!

.Xdefaults should work just fine. To reload .Xdefaults though you should use `xrdb -load` and not `xrdb -merge` -- that is why some changes are not being undone, I believe. In my .Xdefaults file I have a couple of lines that might help:
Code:

URxvt.perl-lib: /home/username/.urxvt/
URxvt.perl-ext-common: default,selection,clipboard

I store my third-party perl scripts in ~/.urxvt instead of messing up my / filesystem. Obviously I have a perl script called "clipboard" in that folder. I'm not sure if the above is completely accurate since I have a couple of other scripts running as well that I edited out (in particular I'm not sure if selection belongs there) but the rest should be relevant.

catkin 06-10-2010 03:21 AM

Thanks T3slider :)

No time to follow up immediately but will do so.


All times are GMT -5. The time now is 07:08 PM.