Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been using w3m for a couple of weeks and am convinced that it is my preferred text browser - with one exception.

Is there any way to yank URLs to the clipboard without using the mouse?

I have looked through the manual and, using the default keybindings, there doesn't appear to be any documented way to do this.

Has anyone developed a script to work around this?

share|improve this question
up vote 10 down vote accepted

Set the “External Browser” option to

sh -c 'printf %s "$0" | xsel'

You can use xsel -b to use the clipboard instead of the primary selection. An alternative to xsel is xclip (xclip for the primary selection, xclip -selection CLIPBOARD for the clipboard).

In ~/.w3m/config, that's the extbrowser setting.

Then press M to copy (yank) the URL of the current page, or ESC M to copy the URL of the link under the cursor.

You can use the second or third external browser for that instead; then the key combination is 2 M or 3 M or 2 ESC M or 3 ESC M.

share|improve this answer
I don't know if you cooked that up on the spot or it is a (little) known workaround, but it is both elegant & effective. Thank you. – jasonwryan May 3 '11 at 23:33
I did. I hadn't realized this was so easy before your question spurred me into looking! Thank you. – Gilles May 3 '11 at 23:43
Colour me impressed :) To put the finishing touches on, I mapped some more intuitive keybinds, (the functions are EXTERN & EXTERN_LINK) and now I am set... – jasonwryan May 4 '11 at 0:25

Have you tried muennich/urxvt-perls? Awesome scripts that can let you select/open URLs, select/copy with keyboard, and handle copy/paste from clipboard. Awesome scripts!

share|improve this answer
Yes, I have been using Bert's perls for a few years now. They don't work in w3m, however. – jasonwryan May 20 '14 at 18:09

If I understand correctly, you need a terminal emulator with a keyboard shortcut to paste test. For example, in Konsole you can do it with Ctrl-Shift-V.

share|improve this answer
Thanks minaev: that was a good suggestion. I installed jukie.net/bart/blog/urxvt-url-yank but, alas, while it works in my term - it doesn't work in w3m... – jasonwryan May 3 '11 at 10:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.