2 of 2
added 176 characters in body
jimmij
  • 47.1k
  • 20
  • 126
  • 137

LESS uses several environment variables to control colors based on termcap library. The list of variable is the following:

export LESS_TERMCAP_mb=$'\E[6m'          # begin blinking
export LESS_TERMCAP_md=$'\E[34m'         # begin bold
export LESS_TERMCAP_us=$'\E[4;32m'       # begin underline
export LESS_TERMCAP_so=$'\E[1;33;41m'    # begin standout-mode - info box
export LESS_TERMCAP_me=$'\E[0m'          # end mode
export LESS_TERMCAP_ue=$'\E[0m'          # end underline
export LESS_TERMCAP_se=$'\E[0m'          # end standout-mode

If you want to set different foreground color just change 3x to something else To change background change or add 4x, eg. to change color of "~" (tilde character) from your question to red foreground and green background set

export LESS_TERMCAP_md=$'\E[31;42m'

With those variables you will colorize search patterns, prompt, and even manuals will be colorful (if you use less as PAGER).

You can also change other less behavior like prompt, try this one:

export LESS='-iR -j4 --shift 5 -P ?n?f%f .?m(file %i of %m) ..?ltlines %lt-%lb?L/%L. :byte %bB?s/%s. .?e(END) ?x- Next\: %x.:?pB%pB\%..%t'

Play with it, have fun.

Note 1

Due to some bug in new groff version you may need to set

export GROFF_NO_SGR=''

as well to change colors.

Note 2 (List of basic color codes)

Foreground:
30 - black
31 - red
32 - green
33 - yellow
34 - blue
35 - magenta
36 - cyan
37 - white

Background:
40 - black
41 - red
42 - green
43 - yellow
44 - blue
45 - magenta
46 - cyan
47 - white

More about color codes: http://en.wikipedia.org/wiki/ANSI_escape_code
jimmij
  • 47.1k
  • 20
  • 126
  • 137