Under Development
stars

Open URLs from Emails#

Prerequisites#

  1. NeoMutt installed and working.

  2. A URL picker installed β€” urlview or urlscan.

  3. A web browser accessible from the command line.

On Fedora/RHEL:

sudo dnf install urlview     # or: pip install urlscan

On Debian/Ubuntu:

sudo apt install urlview     # or: pip install urlscan

On macOS:

brew install urlview         # or: pip install urlscan

Set Up urlview#

  1. Create ~/.urlview with your browser command:

COMMAND xdg-open

On macOS, use:

COMMAND open

Or use the $BROWSER environment variable:

COMMAND $BROWSER
  1. Add a macro to NeoMutt:

macro index,pager \cb "<pipe-message>urlview<Enter>" "Extract and open URLs"
  1. Open a message containing links and press Ctrl-B.

Expected result: urlview displays a numbered list of URLs found in the message. Select one and press <Enter> to open it in your browser.

Set Up urlscan (Alternative)#

urlscan is a more modern alternative with colour support and context display.

  1. Install urlscan:

pip install urlscan
  1. Add the NeoMutt macro:

macro index,pager \cb "<pipe-message>urlscan<Enter>" "Extract and open URLs"
  1. Press Ctrl-B on a message with links.

Expected result: urlscan shows URLs with surrounding context and lets you select one to open.

Configure the Browser#

If links don’t open, set $BROWSER in your shell profile:

# Linux
export BROWSER="xdg-open"

# macOS
export BROWSER="open"

# Specific browser
export BROWSER="firefox"

You can also set it inside NeoMutt:

setenv BROWSER xdg-open

Expected result: selected URLs open in the configured browser.

Pipe Only the Message Body#

By default, <pipe-message> sends the full message including headers. To send only the decoded body:

set pipe_decode = yes

Expected result: urlview/urlscan receives clean body text without header noise.

Copy a URL Instead of Opening It#

urlscan can copy a URL to the clipboard instead of opening it.

macro index,pager \cb "<pipe-message>urlscan --pipe 'xclip -selection clipboard'<Enter>" "Copy URL to clipboard"

Expected result: selecting a URL copies it to the system clipboard.

See Integrate External Tools for more on connecting NeoMutt to external programs.