Yanking URLs in w3m

9,064

Solution 1

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.

Solution 2

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.

Solution 3

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:
9,064

Related videos on Youtube

jasonwryan
Author by

jasonwryan

Updated on September 18, 2022

Comments

  • jasonwryan
    jasonwryan almost 2 years

    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?

  • jasonwryan
    jasonwryan about 13 years
    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
    jasonwryan about 13 years
    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.
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' about 13 years
    I did. I hadn't realized this was so easy before your question spurred me into looking! Thank you.
  • jasonwryan
    jasonwryan about 13 years
    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
    jasonwryan about 10 years
    Yes, I have been using Bert's perls for a few years now. They don't work in w3m, however.
  • Vignesh
    Vignesh over 5 years
    I think this won't work for magnet links, I am getting some Invalid directive errors.
  • Wolf
    Wolf about 5 years
    Defining extbrowser ahead of time isn't required. If you run 2 ESC M or 3 ESC M when it isn't defined, it will prompt you for a command to run, which means you can run any program on the link. You could leave extbrowser 3 always open so as to have a command runner.