How do I open a link from an email in mutt (without using the mouse)?

24

2

One of the things I like about using Mutt is that I don't have to use the mouse pretty much at all. I get a lot of emails that contain links, though, whether they're validation ("click on this link to validate your account") or from Facebook or other similar sites. What I want to know is, is there a way to open these links without clicking on them?

Jonathan

Posted 2011-09-09T18:26:42.827

Reputation: 1 539

Answers

12

I also want to advise using urlscan instead of urlview. Its man page explains what needs to be added to your .muttrc to get it to display your email links. I found it to be better than urlview for two reasons:

  1. It does not truncate URLs like urlview.
  2. It also displays the text in the context of which the URL occurs, which is very helpful when you have an email with many links. In my experience, urlview doesn't do this.

I recently made this switch and have found mutt to be a lot more usable when it comes to opening links from it.

user1953384

Posted 2011-09-09T18:26:42.827

Reputation: 267

The last version that is Python 2 compatible is 0.9.3. Requires: Python 3.3+ and the python-urwid library. – DmitrySandalov – 2019-09-30T09:53:50.630

9

Yes, the easiest method is with the urlview helper utility for mutt. The urlview utility is a curses program designed to be a URL extractor and launcher. The method of installation depends on your target operating system. It can be obtained from the mutt ftp site.

Once installed, place this in your ~/.muttrc:

macro pager \cb 'urlview' 'Follow links with urlview'

You can now use Ctrl + b to launch urlview in the pager.

John T

Posted 2011-09-09T18:26:42.827

Reputation: 149 037

1I had to actually have macro pager \cb <pipe-entry>'urlview'<enter> 'Follow links with urlview' to get this to work. – dpb – 2016-11-22T20:53:53.140

4

An alternative to urlview is w3m, a text based web browser and pager.

macro index,pager \cb ": unset wait_key; set pipe_decode\n|w3m\n: set wait_key; unset pipe_decode\n" "call w3m to extract URLs out of a message"

After typing Ctrl-B to launch w3m, type : (a colon) to tell w3m to convert URL strings to links.

You may also want to w3m's Option Setting Panel (type o) and set the "Treat URL-like strings as links in all pages" to YES. Then you won't have to keep typing : as you page through the message.

garyjohn

Posted 2011-09-09T18:26:42.827

Reputation: 29 085

Is there a way to then open the w3m links in, say, firefox, instead of staying in w3m? – Sparhawk – 2015-10-06T12:47:33.917

1Yes. Open w3m, type o to open the Option Setting Panel, scroll down to "External Program Settings" and set the "External Browser" or "Second External Browser" to "firefox". Select "OK" to save the setting. To use the External Browser, type M to view the current page or <Esc>M to follow a link; to use the Second External Browser, type 2M or 2<Esc>M. – garyjohn – 2015-10-06T14:40:56.877

Thanks. However, it doesn't seem to be working for me. There may be more troubleshooting involved, so I've asked a proper question.

– Sparhawk – 2015-10-06T23:11:13.597

1

A no-plugins alternative (hackish).

macro index,pager gu "| grep -Eom1 '(http|https)://[a-zA-Z0-9./?=_-&]*' > /tmp/mutt_url; google-chrome $(cat /tmp/mutt_url); rm /tmp/mutt_url<enter>"

Pressing gu will find the first url in a highlighted or open email (by grepping for http, change it to whatever you feel is appropriate in your situation) and opening it in chrome.

Boris Churzin

Posted 2011-09-09T18:26:42.827

Reputation: 127