How to enable syntax highlighting in ranger preview?

$ sudo apt-get install highlight

then reopen ranger.


Ranger supports highlight, see http://www.andre-simon.de/doku/highlight/en/highlight.php for details

Install on macOS by running brew install highlight. The list of available themes can be seen under: highlight/<highlight_version>/share/highlight/themes e.g.:

/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 configures highlighting in scope.sh. To use a specific theme, the HIGHLIGHT_STYLE variable should be set, for example: export HIGHLIGHT_STYLE=clarity