Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ubuntu: use source highlighting for`less` output

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 '

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment