You are not logged in.

#1 2014-06-14 09:55:38

fmang
Member
From: France
Registered: 2012-08-14
Posts: 9
Website

Using dmenu to open links from xterm

Hi there,

Not too long ago, I toyed with xterm to make URL selection somewhat similar to urxvt's with url-select. https://bbs.archlinux.org/viewtopic.php?id=181515

Not too satisfied because it requires compiling xterm, I found a simpler solution. First off, you need this little script. I called it grab-urls:

#!/bin/bash

regex='\bhttps?://[^ ]*\b'
function menu { dmenu -p 'Open URL' ; }
function open { dwb -n "$1" ; }

urls="$(grep -Eo "$regex")"
[ -z "$urls" ] && exit
url="$(echo "$urls" | tac | menu)"
[ -n "$url" ] && open "$url"

Next, the trick is to have xterm pipe the content of its scrollback to that script. In your .Xresources:

xterm*printerCommand: /path/to/grab-urls
*VT100.Translations: #override \n\
        Alt <Key>u: print-everything(noAttrs, noNewLine)

After sourcing it with xrdb and restarting xterm, pressing Alt+u should spawn dmenu with the links it found.

This is nothing too fancy, but I thought I'd share it.

Offline

Board footer

Powered by FluxBB