Yanking URLs in w3m

Google

Set the External Browser option

Method One

reference

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 Two

source

you can yank url vim style, supports tmux,linux,macos,windows,android

$EDITOR ~/.w3m/keymap
usage: go to a link and press **yy** to copy url
yank url to multiple clipboard (under cursor)
1
keymap  yy      EXTERN_LINK "url=%s ; printf "%b" "$url" > /tmp/clipbrd.txt ; printf "%b" "$url" | xsel -b 2>/dev/null ; printf "%b" "$url" | tmux load-buffer - ; printf '%s' "$url" | wl-copy 2>/dev/null  ; printf '%s' "$url" | clip 2>/dev/null ; printf '%s' "$url" > /dev/clipboard 2>/dev/null ; printf '%s' "$url" | pbcopy 2>/dev/null ; printf '%s' "$url" | termux-clipboard-set 2>/dev/null"
yank url to multiple clipboard (current page)
1
keymap  YY      EXTERN "url=%s ; printf "%b" "$url" > /tmp/clipbrd.txt ; printf "%b" "$url" | xsel -b 2>/dev/null ; printf "%b" "$url" | tmux load-buffer - ; printf '%s' "$url" | wl-copy 2>/dev/null  ; printf '%s' "$url" | clip 2>/dev/null ; printf '%s' "$url" > /dev/clipboard 2>/dev/null ; printf '%s' "$url" | pbcopy 2>/dev/null ; printf '%s' "$url" | termux-clipboard-set 2>/dev/null"

Last update: Nov 20, 2024