linux:less-syntax-highlight
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 (remove --line-numbers option for better copy&pasting) export LESSOPEN="| $(which highlight) %s --out-format xterm256 --line-numbers --quiet --force --style freya" export LESS=" -R" # remove -N and --line-numbers for better copy&pasting. other options can be defined like this: 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 freya" # 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
On dark terminal, the following themes work well:
bluegreen
ekvoli
freya
moria
solarized-light
To only allow ansi control characters of text files, add to .bashrc
export LESS=" -R"
linux/less-syntax-highlight.txt · Last modified: 2023/05/29 11:55 by 127.0.0.1