Syntax-Highlighting

如何在遊俠預覽中啟用語法突出顯示?

  • February 11, 2022

我看過一些截圖,其中游俠在其預覽視窗中使用語法高亮。所以我想知道如何啟用此功能,發現我需要scope.sh目錄中的文件, 該文件/home/user/.config/ranger/scop.sh將使用命令生成 $ ranger --copy-config=scope。然而,在生成它之後,預覽視窗完全消失了,儘管我插入set use_preview_script truerc.config.

問:有人知道如何在 Ranger 預覽視窗中啟用語法高亮(尤其是 C/C++)嗎?

$ sudo apt install highlight

然後重新打開ranger

Ranger 支持,highlight詳見http://www.andre-simon.de/doku/highlight/en/highlight.php

通過執行在macOS上安裝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

引用自:https://unix.stackexchange.com/questions/435696