Open sealevelcain opened 7 years ago
image/x-imgur-album; xviewer %s; test=test -n "$DISPLAY"
image/*; xviewer '%s'; test=test -n "$DISPLAY"
This is how I got xviewer
to run with rtv everytime I open a picture.
Basically, you can just replace feh -g 640x480
with any other image viewer,
How it works is pretty similar to how you would run an image viewer through the terminal
feh
is the program
-g 640x480
is the program's arguement (this specific arg is to limit the size of the window)
%s
is the file you want to use the program feh
on (in this case, the "file" is going to be a link to an imgur link, as opposed to a normal picture file)
(although I had problems getting other image viewers to work, so I only know that xviewer and feh are the ones compatible so far)
The test=test -n "$DISPLAY"
is meant to check if your terminal is capable of opening GUI applications. However, on macOS the environment variable it is usually not set so these lines might be inadvertently getting skipped. To get it to work, you could to either
$DISPLAY
environment variable to some non-empty value in your .bash_profile
or from the command line E.g. DISPLAY=1 rtv
, ortest=test -n "$DISPLAY"
from the mailcap entry.For preview specifically, I don't think it can display images directly from URLs. You will need to craft some terminal command that can download the image and then pipe it into the preview application. Here's a quick example
image/*; curl -s "%s" | convert - jpg:/tmp/rtv.jpg && open -a Preview /tmp/rtv.jpg
This isn't a great example because it converts to jpg and hard-codes the filename. Also it won't work with image/x-imgur-album
. You might be able to come up with something better yourself. If you do, please share it here and we can improve the mailcap examples.
I'm trying to edit mailcap to allow me to open images in preview, however I'm unsure how to do so. Above is the section I believe I should be editing in mailcap but I don't know how to properly specify that I want to open images with preview (or any other app for that matter). Is this possible?