How to enable source highlighting when doing `less mycodefile.ext`

How to enable source highlighting when doing less mycodefile.ext

  1. Install source-highlight
    sudo apt install source-highlight

  2. Configure it on your .bash_profile

lessWithSourceHighlightSetup() {
  # location of the script may vary
  src_hilite_pipe_script=`dpkg -L libsource-highlight-common | grep lesspipe`
  export LESSOPEN="| ${src_hilite_pipe_script} %s"
  export LESS=' -R '
}


lessWithSourceHighlightSetup
  1. Use it on any code file less -N /path/to/mycode.ext

Screen Shot 2019-11-12 at 9 55 32 AM

Leave a Reply

Your email address will not be published. Required fields are marked *