Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ataias/99a93cf54b08d43c82e2 to your computer and use it in GitHub Desktop.
Save ataias/99a93cf54b08d43c82e2 to your computer and use it in GitHub Desktop.
How to enable syntax-highlighting in less. Use `less -N` (or type -N while in less) to enable line numbers. Based on the procedure described in http://superuser.com/questions/71588
# Enable syntax-highlighting in less.
# Last tested on CentOS 6.3.
#
# First, add these two lines to ~/.bashrc
# export LESSOPEN="| /usr/bin/src-hilite-lesspipe.sh %s"
# export LESS=" -R "
sudo yum -y install boost boost-devel ctags
wget http://springdale.math.ias.edu/data/puias/unsupported/6/x86_64/source-highlight-3.1.6-3.puias6.x86_64.rpm
source-highlight-3.1.6-3.puias6.x86_64.rpm
sudo yum -y install source-highlight
# Enable syntax-highlighting in less.
#
# First, add these two lines to ~/.bashrc
# export LESSOPEN="| /opt/local/bin/src-hilite-lesspipe.sh %s"
# export LESS=" -R "
sudo port install source-highlight
@ataias
Copy link
Author

ataias commented Mar 6, 2016

On mac: brew install source-highlight

and on .bashrc or .zshrc

  ### LESS ###
  # Enable syntax-highlighting in less.
  # brew install source-highlight
  # First, add these two lines to ~/.bashrc
  export LESSOPEN="| /usr/local/bin/src-hilite-lesspipe.sh %s"
  export LESS=" -R "
  alias less='less -m -N -g -i -J --underline-special --SILENT'
  alias more='less'

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