There are many options given in the manual. (See the OPTIONS section.)
Create an RC file: ~/.tmux.conf
. The contents below enables UTF-8, sets the right TERM type, and draws the status bar with a black background and white foreground.
set status-utf8 on
set utf8 on
set -g default-terminal "screen-256color"
set -g status-bg black
set -g status-fg white
In FreeBSD 10.1, I have had to add -g
to the UTF directives.
set -g status-utf8 on
set -g utf8 on
On UTF-8, many SSH clients require one to explicitly define a character set to use. For example, in Putty, select Window -> Translation -> Remote character set: UTF-8
and select Use Unicode line drawing code points
.
And to turn off the status bar...
set -g status off
On colors from the manual...
message-bg colour
Set status line message background colour, where colour is one of:
black, red, green, yellow, blue, magenta, cyan, white, colour0 to
colour255 from the 256-colour palette, or default.
So, to list the available colors, first create a script, maybe colors.sh
:
#!/usr/bin/env bash
for i in {0..255} ; do
printf "\x1b[38;5;${i}mcolour${i}\n"
done
Next, execute the script, piping to less
:
colors.sh | less -r
This produces a list of colors, 1-255, in this format:
colour1
[...]
colour255
Pick a color from the list, perhaps colour240, a shade of grey. In ~/.tmux.conf
, use this value to set the desired color:
set -g status-bg colour240
In Fedora 17, 256-color terminals are not enabled by default. The official method used to enable 256-color terminals by default is given on the Fedora Project Wiki. Follow that guide, or, as a per-user solution, create an alias for tmux to force 256-color support with the "-2" switch.
alias tmux="tmux -2"
Then start tmux to test it.
Note that, as @ILMostro_7 points out, it would not be correct to set the TERM type for tmux
from, for example, ~/.bashrc
. Each tmux pane emulates a terminal - not the same thing as an xterm. The emulation in tmux
needs to match screen, a different terminal description, to behave properly; but, the real terminal does not need to do so. It's description is xterm-256color
.
Trying to run source-highlight
as suggested in the linked question produces this error:
$ source-highlight -o STDOUT -i .bashrc --out-format=esc
source-highlight: could not find a language definition for input file .bashrc
That's because .bashrc
is not recognized automatically by source-highlight
, a quick look through its manual shows that it has the -s
flag to set a language, so what you need is:
source-highlight -s bash -o STDOUT -i .bashrc --out-format=esc | less -R
Best Answer
LESS uses several environment variables to control colors based on termcap library. The list of variable is the following:
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
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:
Play with it, have fun.
Note 1
Due to some bug in new groff version you may need to set
as well to change colors.
Note 2 (List of basic color codes)