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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 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.
Method 2
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!
Method 3
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.
Method 4
you can yank url to tmux or X11 clipboard
$EDITOR ~/.w3m/keymap # EXTERN_LINK = under cursor # EXTERN = current page # yank url to clipboard keymap yy EXTERN_LINK 'tmux set-buffer' keymap YY EXTERN 'tmux set-buffer' keymap yx EXTERN_LINK 'printf %s | xsel -b' keymap YX EXTERN 'printf %s | xsel -b'
usage e.g:
go to a link and press yx to copy url to X11 clipboard
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0