User Tools

Site Tools


linux:less-syntax-highlight

This is an old revision of the document!


Less syntax highlighting

Add the following to ~/.bashrc then reload config or reopen terminal.

### Terminal Syntax Highlighting

# Setup: "apt-get install highlight"

# Pipe Highlight to less
export LESSOPEN="| $(which highlight) %s --out-format xterm256 --line-numbers --quiet --force --style solarized-light"
export LESS=" -R"
alias less='less -m -N -g -i -J --line-numbers --underline-special'
alias more='less'

# Use "highlight" in place of "cat"
alias cat="highlight $1 --out-format xterm256 --line-numbers --quiet --force --style solarized-light"

# Setup JSON Syntax Highlighting
# Copy js.lang to json.lang with the following command
# cp "$(dirname $(brew list highlight | head -n 1))/share/highlight/langDefs/js.lang" "$(dirname $(brew list highlight | head -n 1))/share/highlight/langDefs/json.lang"

Source: https://gist.github.com/textarcana/4611277

linux/less-syntax-highlight.1642692014.txt.gz · Last modified: 2023/05/29 11:53 (external edit)