5

I'm currently working with mutt to get it to display HTML mail properly. I've set up auto_view and a w3m invocation in the mailcap, and this works fine.

However, the URLs for links in received mail are often longer than the width of my terminal window. This makes clicking them inconvenient, because they become split across multiple lines, and I have to manually reconstruct the original URL before I can copy it to the browser.

I've set $markers to off, which successfully removes the plus sign marking a wrapped line. However, mutt is still wrapping the lines on its own (presumably just by echoing \n, since that's what I get on a copy), so it's still inconvenient to get the link.

Is there a way to tell mutt to disable wrapping completely, and just let the terminal emulator handle it? This would allow the links to be copied in one operation. There doesn't seem to be such an option for the $wrap variable; I've tried setting $wrap to far wider than the terminal width, but this doesn't work.

7
  • What does $wrap=0 do for you?
    – tink
    Dec 24, 2018 at 1:31
  • 3
    This is what extract_url was written for.
    – jasonwryan
    Dec 24, 2018 at 1:56
  • @tink 0 is the default, isn't it? In any case, it's the same behavior, unhelpful.
    – Tom Hunt
    Dec 24, 2018 at 6:00
  • @jasonwryan Sadly, the machine running mutt is remote of the machine running my browser, and can't access it. Copy-and-paste from the terminal emulator is the only good way I've found to open a URL.
    – Tom Hunt
    Dec 24, 2018 at 6:01
  • 1
    Can someone provide a link to the exact_url solution? I'm failing to find anything clear about it. Otherwise the set marker = no approach has worked for me when the terminal recognizes and opens links in the default browser.
    – JinnKo
    Jun 9, 2021 at 10:32

2 Answers 2

0

In Debian, I fix this as follows

sudo apt-get install urlview

cat << EOF > ~/.urlview
REGEXP (((http|https|ftp|gopher)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]
COMMAND echo %s > ~/url.txt
EOF

Now when you open mutt, choose an email and then press ctrl+b. This will open a menu listing all of the URLs extracted from the email.

Use the arrow keys to select the URL that you want to open, and press the enter key.

Close mutt, and you'll see the URL has been written to the file url.txt in your $HOME directory. Now it's easy to copy & paste with cat.

Source: https://wiki.archlinux.org/title/Mutt#Viewing_URLs_in_a_web_browser

0

For my following answer, I put

set mailcap_path = "~/.mutt/mailcap"

in my muttrc file and the following settings should be put in the mailcap file, i.e., in ~/.mutt/mailcap.

This is more related to w3m instead of mutt, to be short, you should set:

text/html; w3m -I %{charset} -T text/html -dump -cols 1000; copiousoutput

since the default vaule of cols with dump option on is around 80, which cuts off long urls.

However to see more information about url, I suggest preview as markdown format:

text/html; iconv -t 'UTF-8' -f %{charset} | pandoc -f html -t gfm-raw_html --wrap=none; copiousoutput
2
  • I put that in my .muttrc but now I just get an error text/html: unknown command. What exactly are we supposed to do here by "you should set"? Oct 14, 2022 at 22:17
  • I added the instruction in my answer just now.
    – Jianyu MA
    Oct 15, 2022 at 10:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .