Skip to content

Getting it to work in urxvt #4

Closed

Description

@mgarort

Hi,

I have arrived here following the Reddit post where this plugin was announced. I was very excited to see that the terminal I use, urxvt, was on the list of terminals that support OCS52. However, I haven't been able to make it work. Furthermore, I've seen that urxvt is not on the list of supporting terminals in the GitHub readme, even though it was included in the Reddit post.

Is it possible to use this plugin in urxvt, and do you have any pointers to make it work?

Thanks in advance!

Activity

  1. ojroques commented on Jan 16, 2021

    @ojroques
    Owner

    Hello!

    I initially thought urxvt had support for OSC52 based on a random post saying so (here) and given that rxvt seems to have OSC52 (source). But someone on reddit told me it was not the case. That's why I updated the README here. Sorry for getting your hopes up, I'll update the post on reddit.

    I found this small script claiming to add support maybe it'll be useful to you.

  2. mgarort commented on Jan 16, 2021

    @mgarort
    Author

    Wow, thanks a lot! That script does indeed add support for OSC52, so I can finally use your plugin (and it's great, thanks!).

    For future referece, to add OSC52 functionality to urxvt with this script you need to:

    • Copy the script to ~/.urxvt/ext/52-osc.
    • Make urxvt source it by adding the following line to your ~/.Xdefaults configuration file: URxvt.perl-ext-common: 52-osc.

    Maybe this could be mentioned in the documentation? I know other urxvt users will find it useful too.

  3. ojroques commented on Jan 17, 2021

    @ojroques
    Owner

    Glad to hear that it worked! In case the repo is lost I've created a gist with the script here. I'll update the readme and the reddit post with your instructions. Thanks.

  4. added a commit that references this issue on Jan 17, 2021
  5. nuclight commented on Mar 19, 2025

    @nuclight

    I'll paste script here in case links will be unavailable (first one already, second is unintuitively rendered by GitHub):

    use MIME::Base64;
    use Encode;
    
    sub on_osc_seq {
        my ($term, $op, $args) = @_;
        return () unless $op eq 52;
    
        my ($clip, $data) = split ';', $args, 2;
        if ($data eq '?') {
            my $data_free = $term->selection();
            Encode::_utf8_off($data_free); # XXX
            $term->tt_write("\e]52;$clip;".encode_base64($data_free, '')."\a");
        }
        else {
            my $data_decoded = decode_base64($data);
            Encode::_utf8_on($data_decoded); # XXX
            $term->selection($data_decoded, $clip =~ /c/);
            $term->selection_grab(urxvt::CurrentTime, $clip =~ /c/);
        }
    
        ()
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions