生成配置文件
ranger --copy-config=all # 生成的配置文件在 ~/.config/ranger/ 路径下
代码高亮
apt install highlight
html预览和图片预览
安装预览工具
apt install w3m
apt install w3m-img
编辑配置文件
编辑 ~/.config/ranger/rc.conf 文件
# 开启图片预览
set preview_images true
# 预览图片的方式,默认就是使用 w3m 预览
set preview_images_method w3m
PDF文件预览
安装预览工具
apt install pdftotext # pdf 预览。也可以下载XpdfReade,里面包含pdftotext
编辑配置文件
编辑 ~/.config/ranger/scope.sh
# PDF documents:
pdf)
try pdftotext -l 10 -nopgbrk -q "$path" - && \
{ dump | trim | fmt -s -w $width; exit 0; } || exit 1;;
ranger默认使用 pdftotext 预览pdf文件
docx, doc, xlsx文件预览
安装浏览工具
# doc预览
apt-get install catdoc
# docx预览
apt-get install docx2txt
# xlsx预览
apt-get install xlsx2csv
编辑配置文件
编辑 ~/.config/ranger/scope.sh
# Doc documents
doc)
try catdoc "$path" && { dump | trim | fmt -s -w $width; exit 0; }|| exit 1;;
# Docx documents:
docx)
try docx2txt < "$path" && { dump | trim | fmt -s -w $width; exit 0; }|| exit 1;;
# Xlsx documents:
xlsx)
try xlsx2csv "$path" && { dump | trim | fmt -s -w $width; exit 0; }|| exit 1;;