Open URLs from Emails#
Prerequisites#
NeoMutt installed and working.
A URL picker installed β
urlvieworurlscan.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#
Create
~/.urlviewwith your browser command:
COMMAND xdg-open
On macOS, use:
COMMAND open
Or use the $BROWSER environment variable:
COMMAND $BROWSER
Add a macro to NeoMutt:
macro index,pager \cb "<pipe-message>urlview<Enter>" "Extract and open URLs"
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.
Install urlscan:
pip install urlscan
Add the NeoMutt macro:
macro index,pager \cb "<pipe-message>urlscan<Enter>" "Extract and open URLs"
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.