Skip to content

Instantly share code, notes, and snippets.

Last active February 22, 2023 18:43
What would you like to do?
Following Terminal Links with URLview

Following Terminal Links with URLview

Link handling

Specify what you want urlview to open your links with in ~/.urlview after COMMAND. I.e. the line below will make urlview open all urls in Firefox.

COMMAND firefox

I use this link handler to be run by urlview. This will open images in feh, movies/gifs in mpv on loop, will download .pdfs and music files and will open everything else in my browser.

Tell me how to improve this script, since I literally just threw it together a couple days ago.

Getting URLview built into some programs

Here are the configurations I have to get URLview working on some of my main terminal programs.


This sets u to bring up urlview. IIRC it will give you all urls in the open document.

:noremap <leader>u :w<Home>silent <End> !urlview<CR>


urlview is a total life-saver in newsboat. I can browse even twitter feeds in the terminal with it with all multimedia. I map it to capital U here.

external-url-viewer "urlview"
bind-key U show-urls


Again, I map urlview to capital U in mutt as well.

macro index,pager U "<enter-command>set pipe_decode = yes<enter><pipe-message>urlview<enter><enter-command>set pipe_decode = no<enter>""view URLs"
Copy link

What about youtube/vimeo? I've found a solution but it looks a bit ugly.

mpvFiles="mkv mp4 avi mov wmv flv gif"
fehFiles="png jpg jpeg jpe"
wgetFiles="mp3 flac opus mp3?source=feed pdf"

if echo $fehFiles | grep -w $ext > /dev/null; then
	nohup gpicview "$1" >/dev/null &
elif echo $mpvFiles | grep -w $ext > /dev/null; then
	nohup mpv --loop --quiet "$1" > /dev/null &
elif echo $wgetFiles | grep -w $ext > /dev/null; then
	nohup wget "$1" >/dev/null &
elif echo $1 | grep youtube > /dev/null; then
	nohup mpv "$1" > /dev/null &
elif echo $1 | grep > /dev/null; then
	nohup mpv "$1" > /dev/null &
elif echo $1 | grep vimeo > /dev/null; then
	nohup mpv "$1" > /dev/null &
	nohup firefox "$1" >/dev/null &

And it would be nice if we could send gotten playlist to file or even to mpv directly.
curl | grep youtube | urlview

Copy link

ghost commented Jul 18, 2018

Thanks a lot Luke.
all of them works perfectly.
But do you know how I can make it work with NEOVIM?

Copy link

g4570n commented Sep 22, 2019

The file is not available, I get: "ERROR 404: Not Found"

Copy link

kcallis commented Oct 2, 2019

I am actually looking for the .urlview file. I looked at the dotfile repo, but no such luck...

Copy link

3ruce commented Oct 30, 2019

This works for me in Neovim on Debian 10

" Use urlview to choose and open an url:
" The "leader" key is "\"
noremap <leader>u :w \| startinsert \| term urlview %<cr>

Copy link

bronzehedwick commented Jan 14, 2020

Old thread, but I wanted urlview to work in terminal mode, since Github and others display PR URLs after push. None of these solutions work with terminal mode, unfortunately, because urlview expects a file name, and terminal buffers aren't quite files (I'm not an expert by any stretch, but whatever type of thing terminal buffers are, urlview doesn't like it).

I came up with a kludge that works in terminal mode, by simply writing a temp file.

if executable('urlview')
  function! UrlView() abort
    :silent write /tmp/nvim-urlview.out
    :split term://urlview\ /tmp/nvim-urlview.out
  nnoremap <leader>g :call UrlView()<CR>

Copy link

Benjman commented Jul 1, 2020

@kcallis there should be a sample .urlview at one in /etc/urlview/system.urlview

Copy link

Benjman commented Jul 16, 2020

Copy link

@Benjman , @g4570n
it's kind late, but
now it's calling linkhandler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment