ranger初始配置

ranger是一个基于Python的, vim风格键绑定的, 命令行基础的文件管理器

安装

sudo apt-get install ranger
# cp /etc/ranger/data/scope.sh ~/.config/ranger/
ranger --copy-config=scope

# 如果想定制rc.conf
ranger --copy-config=rc

~/.config/ranger/rc.conf:

set preview_images true
set preview_images_method iterm2
set colorscheme solarized
set vcs_aware true

配置

增加pdf预览功能

sudo apt-get install poppler-utils

增加Highlight预览

sudo apt-get install highlight

macOS

brew install w3m lynx highlight atool mediainfo poppler libcaca imlib2

Tips

  • 预览状态下, 按i键可以滚动预览窗口
  • 按V选中多个文件, 然后:bulkrename可以用vim进行批量重命名

iTerm2 中显示图片

update: 2018-01-23

参见: https://github.com/ranger/ranger/wiki/Image-Previews

iTerm2实现了一种类似于w3mimgdisplay的图片显示协议:

例如,在iTerm2里: (SSH也可以哦~ 但在tmux里没试成)

wget https://iterm2.com/utilities/imgcat -O imgcat
chmod +x imgcat
./imgcat blahblah.jpg

而Ranger也内建了对iTerm2的这种图像显示协议的支持。

只需要:

  • Add the line set preview_images true to your ~/.config/ranger/rc.conf.
  • Add the line set preview_images_method iterm2 to your ~/.config/ranger/rc.conf.

更多参见man rangerPREVIEWS一节。

See Also

注意: root用户预览功能被禁用

https://github.com/ranger/ranger/issues/429:

After some talk on IRC, the issue was that the file previews are disabled for the root user.