如何在 Ranger 预览中启用语法突出显示?

如何在 Ranger 预览中启用语法突出显示?

我见过一些 Ranger 在预览窗口中使用语法突出显示的屏幕截图。所以我想知道如何启用此功能,并发现我需要scope.sh目录中的文件 /home/user/.config/ranger/scop.sh,该文件将使用命令生成 $ ranger --copy-config=scope。然而,生成后预览窗口完全消失,尽管我插入set use_preview_script truerc.config.

问:有人知道如何在 Ranger 预览窗口中启用语法突出显示(尤其是 C/C++)吗?

答案1

$ sudo apt install highlight

然后重新打开ranger

答案2

游侠支持highlight,请参阅https://gitlab.com/saalen/highlight欲了解详情

安装于苹果系统通过跑步brew install highlight。可用主题列表可以在以下位置查看: highlight/<highlight_version>/share/highlight/themes例如:

/usr/local/Cellar/highlight/3.54/share/highlight/themes$ ls 

base16             clarity.theme              easter.theme             edit-vim.theme    molokai.theme       relaxedgreen.theme
acid.theme         dante.theme                edit-anjuta.theme        edit-xcode.theme  moria.theme         rootwater.theme
aiseered.theme     darkblue.theme             edit-bbedit.theme        ekvoli.theme      navajo-night.theme  seashell.theme
andes.theme        darkbone.theme             edit-eclipse.theme       fine_blue.theme   navy.theme          solarized-dark.theme
anotherdark.theme  darkness.theme             edit-emacs.theme         freya.theme       neon.theme          solarized-light.theme
autumn.theme       darkplus.theme             edit-fasm.theme          fruit.theme       night.theme         sourceforge.theme
baycomb.theme      darkslategray.theme        edit-flashdevelop.theme  github.theme      nightshimmer.theme  tabula.theme
bclear.theme       darkspectrum.theme         edit-gedit.theme         golden.theme      nuvola.theme        tcsoft.theme
biogoo.theme       denim.theme                edit-godot.theme         greenlcd.theme    olive.theme         the.theme
bipolar.theme      duotone-dark-earth.theme   edit-jedit.theme         kellys.theme      orion.theme         vampire.theme
blacknblue.theme   duotone-dark-forest.theme  edit-kwrite.theme        leo.theme         oxygenated.theme    whitengrey.theme
bluegreen.theme    duotone-dark-sea.theme     edit-matlab.theme        lucretia.theme    pablo.theme         xoria256.theme
breeze.theme       duotone-dark-sky.theme     edit-msvs2008.theme      manxome.theme     peaksea.theme       zellner.theme
bright.theme       duotone-dark-space.theme   edit-nedit.theme         maroloccio.theme  print.theme         zenburn.theme
camo.theme         dusk.theme                 edit-purebasic.theme     matrix.theme      rand01.theme        zmrok.theme
candy.theme        earendel.theme             edit-vim-dark.theme      moe.theme         rdark.theme

Ranger 在scope.sh.要使用特定主题,HIGHLIGHT_STYLE应设置该变量,例如:

export HIGHLIGHT_STYLE=clarity

相关内容