On 14/07/18 02:08, Thoralf Dassler wrote:
Hi all,
trying to configure ranger for the first time. I have a bunch of
files, for which ranger tells me:
---File Type Classification---
SMTP mail, ASCII text
or
---File Type Classification---
SMTP mail, ASCII text, with very long lines
The file name of these is just an integer number, N (1, 2, 3, 4,
..., 219, ...), without a file extension.
On the command line (not running ranger) I use a utility, which
takes N as an argument: 'show N'. This displays the content of
N in a formatted way ('formatted' means: only display
certain parts of the file contents, and filter out other parts).
I'd like ranger to use 'show N' as auto-preview for these files.
I suspect I'd have to do four things within ranger's config
files:
1) have a condition for 'SMTP mail ASCII text' (with or without
very long lines)
2) while running ranger: for the condition, pick N to which I
navigate
3) pass N as an argument to 'show'
4) make ranger do 'show N'
Hope someone can help.
Many thanks,
Thoralf
Hello,
Conveniently, ranger comes with a tool for doing file previews called
`scope`, which in turn uses the configuration file at
`~/.config/ranger/scope.sh`. Use `ranger --copy-config=scope` if you
don't have that file yet.
In that file you will notice that scope can figure out how to handle a
file either by looking at its extension or its mimetype. Since your
files have no extension, you most likely want to use mimetypes. To
figure out the mimetype of your file, do `mimetype N` on one of your
files. You will probably get `message/rfc822`, meaning you would add
something like the following in the mimetype case:
message/rfc822)
try my_show_program "$path" && { dump | trim; exit 0; }
Also take a look at `~/.config/ranger/rifle.conf` for opening (as
opposed to previewing) files.
Good luck,
Dimitri