Running irssi in a tmux session on a remote server I had the problem to open urls in GUI browser.
Using openurl.pl
lets me easily open urls from within irssi in w3m.
As irssi is running on a remote server with out X this seemed quite reasonable, but sometimes you just need a more modern approach -- JavaScript, Video etc pp.
Searching for a solution I found
this
tutorial how to setup openurl to write to a FIFO
and to read from it
with a shell script.
As I liked opening the URL first in w3m and hence w3m has a command to
open the current url in an external browser with 'M' I decided to modify
above solution to have w3m write to the FIFO
.
First create the FIFO
on the remote machine:
$ mkfifo ~/.w3m/url-pipeThen open w3m on the remote machine, press 'o' and then go to the first link
[External Viewer Setup]
, scroll down to find the 'External
Program Settings' section.
Clear all external browser settings and configure the first option to use
echo '%s' > ~/.w3m/url-pipeNavigate to the next
[OK]
and press enter to save your changes.
Create a shell script, I called it w3m-url-consumer.sh
:
#!/bin/bash ssh -n $HOSTNAME "tail -f ~/.w3m/url-pipe" | while read url; do sensible-browser "$url"& done > /tmp/garbishReplace
$HOSTNAME
with the actual hostname of your server.
Create some autostart thingy for it or make sure it is running when you
need it.
Hint: Inside irssi use
/set openurl_app_http tmux split-window w3m "$1"to open w3m in a split pane.
Last modified: 2023-11-15T13:37:37Z