0x01 Intro

Ranger 是一个使用vim键位基于python的终端文件管理器,vim用户可以很快上手ranger

官方guide:https://github.com/ranger/ranger/wiki/Official-User-Guide

image-20221101092958468

0x02 install

Github地址:https://github.com/ranger/ranger

使用pip安装ranger

1
pip install ranger-fm

包管理homebrew 安装rangera

1
$ brew install ranger     

安装完成后首次首次运行需要安装配置文件,默认不会生成

0x03 configuration

Ranger 使用四个主要的配置文件

* `rc.conf`设置配置变量和键位映射
* `rifle.conf`设置默认程序
* `scope.sh`是一个shell脚本,用来ranger内的预览
* `commands.py`包含ranger内操作函数,可以自己定义不同操作

生成ranger配置文件

1
2
ranger --copy-config=rc    (rc,rifle,scope,commands)
ranger --copy-config=all (生成全部文件)

默认配置文件路径在~/.config/ranger

0x004 previews

安装preview 插件

参考github 主页

For enhanced file previews (with scope.sh):

  • img2txt (from caca-utils) for ASCII-art image previews
  • w3mimgdisplay, ueberzug, mpv, iTerm2, kitty, terminology or urxvt for image previews
  • convert (from imagemagick) to auto-rotate images
  • rsvg-convert (from librsvg) for SVG previews
  • ffmpeg, or ffmpegthumbnailer for video thumbnails
  • highlight, bat or pygmentize for syntax highlighting of code
  • atool, bsdtar, unrar and/or 7z to preview archives
  • bsdtar, tar, unrar, unzip and/or zipinfo (and sed) to preview archives as their first image
  • lynx, w3m or elinks to preview html pages
  • pdftotext or mutool (and fmt) for textual pdf previews, pdftoppm to preview as image
  • djvutxt for textual DjVu previews, ddjvu to preview as image
  • calibre or epub-thumbnailer for image previews of ebooks
  • transmission-show for viewing BitTorrent information
  • mediainfo or exiftool for viewing information about media files
  • odt2txt for OpenDocument text files (odt, ods, odp and sxw)
  • python or jq for JSON files
  • jupyter nbconvert for Jupyter Notebooks
  • fontimage for font previews
  • openscad for 3D model previews (stl, off, dxf, scad, csg)
  • draw.io for draw.io diagram previews (drawio extension)

选择性安装预览插件

1
2
3
4
5
6
7

$ brew install caca-utils # img2txt 图片
$ brew install highlight # 代码高亮
$ brew install atool  # 存档预览
$ brew install w3m # html页面预览
$ brew install poppler # pdf预览
$ brew install mediainfo # 多媒体文件预览

0x05 usage

基本光标操作类似于vim 使用hjkl控制光标操作

  • i检查预览文件,可以使用滚动操作
  • q退出ranger

按键绑定

Command hints show up whenever a mapping has multiple continuations:
g for navigation and tabs
r for :open_with command
y for yank(copy)
d for cut/delete
p for paste
o for sort
. for filter_stack
z for changing settings
u for “undo”
M for linemode
+, -, = for setting access rights to files