You are not logged in.

#1 2010-08-11 21:23:36

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

urxvt-url-select - open/copy URLs in urxvt using only the keyboard

Hi,

I've finished solo-testing my first real perl extension for the rxvt-unicode terminal emulator.

I post it here because it might be of interest for others: url-select. Just copy the linked file into "/usr/lib/urxvt/perl/" to install it.

It's based on -- initially forked, but at the end only inspired by -- mark-yank-urls. I've written my own version, because mark-yank-urls did not suspend terminal updates while cycling through the URLs, which causes a lot of distortions.

To activate this extension, put the following lines into your .Xdefaults:

URxvt.perl-ext-common: ...,url-select
URxvt.urlLauncher:     firefox
URxvt.underlineURLs:   true
URxvt.keysym.M-u:      perl:url-select:select_next

The meaning of the lines should be self-explanatory. The "..." in the first line means, that you have to append "url-select", if a line with the same key already exists in your .Xdefaults.

After that, you could start URL selection mode by hitting Meta-U. Subsequent key-presses cycle through the available URLs from bottom to top. You could also use the 'j/k' keys to select the next down-/upward URL. Escape cancels the selection mode, 'y' copies the currently selected URL to the primary buffer and the Return key opens it using the specified browser ("urlLauncher", see above).

Please notice one last difference to the original mark-yank-urls extension: When activating the URL selection mode, the search starts at the last line of the currently visible area, whereas the original extension starts at the last line of the complete text buffer.

Enjoy or move on,
Bert

Last edited by ber_t (2011-03-29 12:38:30)

Offline

#2 2010-08-11 23:03:37

dawn
Member
Registered: 2008-01-15
Posts: 51

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

Thank you.

I'll make a PKGBUILD for it when I have time.

Offline

#3 2010-08-11 23:12:40

egan
Member
From: Mountain View, CA
Registered: 2009-08-17
Posts: 273

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

It's nice to see another example of this, since mark-yank-urls hasn't worked very well for me.

It would be nice if you could add a general copy mode too. It's a shame that you have to run a shell inside of a tmuxer to get what I consider to be an integral function all terminals need: marking and yanking text. Really URLs are just a subset of that.

Your code looks a little more clean than mark-yank-urls, so I will be using it to explore the possibility of implementing my own script. Of course if yours turns out well, then I won't need to!

Also just for others' information, they can also put the script somewhere local such as ~/.urxvt and include the location using:
URxvt.perl-lib:

EDIT: After trying to test this, I haven't gotten it to work once unfortunately. It works with urxvtc right?

Last edited by egan (2010-08-11 23:52:26)

Offline

#4 2010-08-12 08:19:11

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

dawn wrote:

I'll make a PKGBUILD for it when I have time.

I thought of that myself but refused to do so, because it's just one script that you have to download and move into a specific directory on your computer. The hardest part is to modify your .Xdefaults, what pacman can't do for you.

But I'll sure appreciate it, if you do so!


egan wrote:

It would be nice if you could add a general copy mode too. It's a shame that you have to run a shell inside of a tmuxer to get what I consider to be an integral function all terminals need: marking and yanking text. Really URLs are just a subset of that.

I already thought of that, too. But personally I think that the mouse is much more elegent for selecting text. But I'll try to implement this just for the fun of it -- it shouldn't be that hard.

egan wrote:

EDIT: After trying to test this, I haven't gotten it to work once unfortunately. It works with urxvtc right?

Yes, I've just checked this!

Offline

#5 2010-08-12 08:34:56

Ogion
Member
From: Germany
Registered: 2007-12-11
Posts: 367

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

Works for me (in urxvtc), very nice. Thanks for this, ber_t.

Ogion

Last edited by Ogion (2010-08-12 08:36:05)


(my-dotfiles)
"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
"Enlightenment is man's leaving his self-caused immaturity." - Immanuel Kant

Offline

#6 2010-08-12 12:31:41

steve___
Member
Registered: 2008-02-24
Posts: 452

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

@ber_t - The upside to adding it to AUR is if/when you release any modifications to the script, all users will get a copy on their next update.

Last edited by steve___ (2010-08-12 13:12:23)

Offline

#7 2010-08-12 13:01:16

dawn
Member
Registered: 2008-01-15
Posts: 51

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

@ber_t, I uploaded my PKGBUILD to the AUR, but I'm not I should've called it ...-git. Anyway, I hope you only push stable versions to the master branch.

Offline

#8 2010-08-12 13:02:39

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

steve___ wrote:

@ber_t - The upside to adding it to AUR is if/when you release any modifications to the script, all user will get a copy on their next update.

You're absolutely right! I'll write/upload it in the next few hours...

Offline

#9 2010-08-12 13:14:19

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

dawn wrote:

@ber_t, I uploaded my PKGBUILD to the AUR, but I'm not I should've called it ...-git. Anyway, I hope you only push stable versions to the master branch.

Argh, parallel posting...

Thank you, but I may upload one for myself. I plan to use version tags on the master branch. I will also bundle the whole set (currently two, more work in progress) of the urxvt-perls repository, because tags only make sense this way.

Please also notice that url-select does not require perl-clipboard.

Offline

#10 2010-08-12 13:24:46

dawn
Member
Registered: 2008-01-15
Posts: 51

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

ber_t wrote:
dawn wrote:

@ber_t, I uploaded my PKGBUILD to the AUR, but I'm not I should've called it ...-git. Anyway, I hope you only push stable versions to the master branch.

Argh, parallel posting...

Thank you, but I may upload one for myself. I plan to use version tags on the master branch. I will also bundle the whole set (currently two, more work in progress) of the urxvt-perls repository, because tags only make sense this way.

Please also notice that url-select does not require perl-clipboard.


Yeah wasn't sure about perl-clipboard. Should've tested it. I'll find a way to remove mine, then.

EDIT: or maybe if you'd like to keep that name, I'll disown it and you can maintain it.

Last edited by dawn (2010-08-12 13:26:28)

Offline

#11 2010-08-12 13:49:01

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

dawn wrote:

EDIT: or maybe if you'd like to keep that name, I'll disown it and you can maintain it.

You could also keep your version online. I will not use the -git suffix because I will use only the tagged and thus stable versions, whereas your PKGBUILD uses the current master ref.

Last edited by ber_t (2010-08-12 13:50:34)

Offline

#12 2010-08-12 14:31:52

VCoolio
Member
From: Netherlands
Registered: 2010-01-05
Posts: 120

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

Nice script, thank you, but there is a problem: while scrolling through links using j and k it also passes those characters (allthough you don't see that while using them). So, using urxvt, tmux and weechat, if I highlight an url and hit enter, it opens the website but also enters j's and/or k's into the chatroom. The same in the shell, where it results in 'command not found'. I hope you can fix that.

Offline

#13 2010-08-12 14:35:59

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

Finally, I've uploaded my own PKGBUILD. Turns out there is a Download-Section on GitHub, I've never seen before, which renders the usage of tags unnecessary and allows to package only parts of the repo.

Offline

#14 2010-08-12 14:39:18

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

VCoolio wrote:

but there is a problem: while scrolling through links using j and k it also passes those characters (allthough you don't see that while using them).

I could not confirm this. I've had this problems in the past but one of the last commits should fix that. Did you accidentally download an older version?

Offline

#15 2010-08-12 16:59:00

egan
Member
From: Mountain View, CA
Registered: 2009-08-17
Posts: 273

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

ber_t wrote:
egan wrote:

It would be nice if you could add a general copy mode too. It's a shame that you have to run a shell inside of a tmuxer to get what I consider to be an integral function all terminals need: marking and yanking text. Really URLs are just a subset of that.

I already thought of that, too. But personally I think that the mouse is much more elegent for selecting text. But I'll try to implement this just for the fun of it -- it shouldn't be that hard.

egan wrote:

EDIT: After trying to test this, I haven't gotten it to work once unfortunately. It works with urxvtc right?

Yes, I've just checked this!

Well some of us don't like the mouse... wink

I will look into it some more to see if I can get it to work.

Offline

#16 2010-08-13 04:52:08

livibetter
Member
From: Taipei
Registered: 2008-05-14
Posts: 95
Website

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

I just installed on my system. It works for urxvt/urxvtc (you don't need to restart urxvtd, just open a new window).

I think the greatest thing of it is it won't interrupt when I try to open a link from Vim, the middle mouse button will paste stuff from clipboard into my text. This url-select won't have such problem.

Offline

#17 2010-08-13 15:07:00

VCoolio
Member
From: Netherlands
Registered: 2010-01-05
Posts: 120

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

ber_t wrote:
VCoolio wrote:

but there is a problem: while scrolling through links using j and k it also passes those characters (allthough you don't see that while using them).

I could not confirm this. I've had this problems in the past but one of the last commits should fix that. Did you accidentally download an older version?

No, I have the latest here 13/08 17:00 CET. Does it matter that I have perl 5.12.1-1? Also I manually compiled urxvt 9.07 to enable something I forgot.
Edit: strange thing: the j's and k's need only one backspace strike to delete them all.

Last edited by VCoolio (2010-08-13 15:09:06)

Offline

#18 2010-08-13 16:31:44

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

VCoolio wrote:

No, I have the latest here 13/08 17:00 CET. Does it matter that I have perl 5.12.1-1? Also I manually compiled urxvt 9.07 to enable something I forgot.
Edit: strange thing: the j's and k's need only one backspace strike to delete them all.

Did you rebuild your urxvt after the perl 5.12.1 update? See this for more information: http://bugs.archlinux.org/task/20352

Offline

#19 2010-08-13 20:24:28

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

Updated to version 1.1

Pressing an unused key does not cause scrolling to the end of the buffer anymore.

Offline

#20 2010-08-14 09:57:25

VCoolio
Member
From: Netherlands
Registered: 2010-01-05
Posts: 120

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

ber_t wrote:

Did you rebuild your urxvt after the perl 5.12.1 update? See this for more information: http://bugs.archlinux.org/task/20352

Ah, that's probably it, should have thought of that. Will try that soon; if you don't hear from me anymore you have a happy customer. Thanks.

Offline

#21 2010-08-14 21:37:54

StephenB
Member
From: UK
Registered: 2010-04-25
Posts: 18

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

I've updated the wiki page and replaced mark-yank-urls with urxvt-url-select.
http://wiki.archlinux.org/index.php/Rxv … elessly.29

I'll keep the my mark-yank-urls pkg in the AUR just incase anyone still wants to use that one.

EDIT: Almost forgot to mention. I found you have to have your mouse over the terminal window in order to enter selection mode (at least this is so with xmonad WM), I've added this as a note on the wiki. The original mark-yank-urls also suffered from this problem.

Last edited by StephenB (2010-08-14 21:41:19)

Offline

#22 2010-08-14 22:35:15

Ogion
Member
From: Germany
Registered: 2007-12-11
Posts: 367

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

Are you sure that that isn't just because of sloppy focuse, i.e. Focus-follows-mouse, so the urxvt has to have focus?

Ogion


(my-dotfiles)
"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
"Enlightenment is man's leaving his self-caused immaturity." - Immanuel Kant

Offline

#23 2010-08-14 23:04:00

StephenB
Member
From: UK
Registered: 2010-04-25
Posts: 18

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

Are you sure that that isn't just because of sloppy focuse, i.e. Focus-follows-mouse, so the urxvt has to have focus?

Very sure. My xmonad draws a large yellow box around the window with focus (so that I can't get confused which one it is). So, if my mouse is over Firefox, and urxvt has focus (that's where my keyboard input goes), then if I press Alt+U, nothing happens. But if I move my mouse over urxvt, then it works. Maybe it is just xmonad being strange, if no one else has this problem?

Offline

#24 2010-08-14 23:16:43

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

StephenB wrote:

Are you sure that that isn't just because of sloppy focuse, i.e. Focus-follows-mouse, so the urxvt has to have focus?

Very sure. My xmonad draws a large yellow box around the window with focus (so that I can't get confused which one it is). So, if my mouse is over Firefox, and urxvt has focus (that's where my keyboard input goes), then if I press Alt+U, nothing happens. But if I move my mouse over urxvt, then it works. Maybe it is just xmonad being strange, if no one else has this problem?

For me it works as expected in dwm using sloppy-focus. The selection mode is activated when the window has the focus regardless of the mouse cursor position.

Offline

#25 2010-08-15 07:30:11

Ogion
Member
From: Germany
Registered: 2007-12-11
Posts: 367

Re: urxvt-url-select - open/copy URLs in urxvt using only the keyboard

Well for me in i3 it works with the mouse elsewhere too. Like i would move the mouse to another window, get focus back to my urxvtc by keyboard command and then alt-u works.

Ogion


(my-dotfiles)
"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
"Enlightenment is man's leaving his self-caused immaturity." - Immanuel Kant

Offline

Board footer

Powered by FluxBB