I have 256 colors working just fine in konsole,
. I thought I'd give tmux
a try because, unlike screen, it seems to support vi
mode. However I find that the colors of my prompt show up and this is most likely because I have a 256 color mode prompt. What do I need to do to get tmux
to recognize all 256 colors?

- 65,642

- 59,188
- 74
- 187
- 252
10 Answers
The Tmux FAQ explicitly advises against setting TERM to anything other than screen
or screen-256color
or tmux
or tmux-256color
in your shell init file, so don't do it!
Here's what I use:
~$ which tmux
tmux: aliased to TERM=xterm-256color tmux
and in in my .tmux.conf:
set -g default-terminal "screen-256color"
Aliasing tmux
to "tmux -2
" should also do the trick.
And don't forget to restart your tmux server: (see @mast3r answer)
tmux kill-server && tmux
-
11I like the way to set it in the .tmux.conf best... using the shell to set it just doesn't seem right – xenoterracide Aug 24 '10 at 05:38
-
6Weird. You don't need
tmux -2
on OSX but you need it with Gnome Terminal. Thanks for the info, added to my aliases! – F.X. Dec 08 '12 at 16:53 -
1In Kubuntu 13.10 the .tmux.conf setting alone did not get me my 256 colors back (which took out highlighting in vim visual mode) but the alias worked. Would certainly prefer a .tmux.conf file only solution. – Jacob Dalton Dec 07 '13 at 21:53
-
1ssh'd into an Ubuntu machine (from OS X Terminal), the .tmux.conf default-terminal was all I needed. – duelin markers Mar 13 '14 at 16:19
-
Here is a relevant ticket: http://sourceforge.net/p/tmux/tickets/67/ ("tmux always sets TERM=screen").
There is an entry in
– blueyed Aug 08 '14 at 15:40TODO
(source): "use screen-256color when started on 256 colour terminal?" -
2for me it seems like all I need to do is
TERM=screen-256color tmux
without creating a.tmux.conf
file. Am I missing something? – joelostblom Apr 26 '15 at 12:41 -
256 color reference: https://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg
set status-bg colourX
– Cody Moniz Mar 28 '16 at 19:18 -
Thank you very much for this. I was going crazy because text of some applications was being rendered as black text on a black background. – mbarkhau Feb 16 '17 at 08:55
-
I lost color when I ssh'd into a different machine, this solves it! – Kevin Jung Sep 17 '17 at 14:37
-
and don't forget to restart the tmux server! tmux kill-server && tmux. Thanks to @mast3r – sreenivas Apr 03 '20 at 00:01
-
Tried each solution above (TERM=xterm-256color,
tmux -2
, and .tmux.conf) and only the .tmux.conf worked for me. Restarting tmux server is not required. I'm running Ubuntu 20.04.1. – Fred Qian Dec 05 '20 at 04:46 -
1
tmux kill-server
- I set everything neovim asked me to do and yet :checkhealth errors didnt go away after I changed my .tmux.conf. kill-server made the changes take place - thanks! – walnut_salami Feb 01 '21 at 17:20 -
This is somewhat wrong.
$TERM
outside of tmux (ie, before you launch it) MUST match your physical terminal (xterm-256color, vt100, etc).$TERM
inside tmux is what should bescreen*
or preferrablytmux*
(but not everyone has a tmux term type installed globally). Setting TERM=tmux before launching tmux only happens to work if your actual terminal is xterm based which is whattmux-256color
was originally derived from. – Dave Aug 31 '22 at 23:32 -
Ty sir for this very beautifully done and straight forward solution, saved me from the rabbit hole of debugging
tmux
. – EsmaeelE Aug 19 '23 at 12:13
Try setting 256 colors explicitly in your bashrc or zshrc:
export TERM=xterm-256color
or
export TERM=screen-256color
If you have problems with tmux not clearing the background colors correctly when using the screen term setting, you can try:
export TERM=screen-256color-bce

- 1,076
-
2the first one is my default TERM setting... I just tried the other 2 and my prompt still doesn't show colors once I enter tmux. (I would like to note that tmux does show colors at the bottom)... it seems that when I enter tmux that it resets the TERM to TERM=screen... perhaps theres a way to override this in a config? – xenoterracide Aug 23 '10 at 09:17
-
nvm... I guess putting it in a my shell's rc does work... how annoying that it ignores the TERM env variable that's set when I execute tmux... I guess I'll have to put a conditional in my rc. – xenoterracide Aug 23 '10 at 09:21
-
1-bce is not compatible with tmux. Tmux does not support background color erase: – Dustin Kirkland Jan 15 '12 at 14:32
-
This (first one) is the only thing that worked for me so far, after trying lots of other suggestions. Finally consistent! – Alex Shroyer Feb 21 '14 at 19:48
-
This seems to be the only thing that works for me, too. I tried
tmux -2
+set -g default-terminal "screen-256color"
without success.export TERM=...
works out of the box, no need for eithertmux -2
orset -g ...
. On Manjaro, btw. – Sebastian Graf Feb 23 '14 at 13:29 -
1I had this problem with roxterm. Hopefully adding roxterm to this will help people find the same solution that I had. I would end up in vim and selecting lines would make them dissappear. Extremely difficult to search for. roxterm by default sets up with just $TERM=xterm, which is no good. – BeepDog Jul 08 '14 at 01:54
-
9-1, you shouldn't set either unconditionally in your shell initialization file. Setting it to
xterm-256color
will override it inside tmux as well, and setting it toscreen-256color
outside of tmux could lead to display bugs. – Alexia Luna Nov 05 '14 at 14:23 -
This advice is the only thing that worked for me running
tmux 2.1
, but caused other problems. After upgrading to2.6
, I was able to usetmux-256color
and everything works much better – zzxyz Jul 27 '18 at 19:15
As per the tmux FAQ, add this to your ~/.tmux.conf
:
set -g default-terminal "screen-256color"
Then add this alias for tmux:
alias tmux='tmux -2'
No need to override the TERM
variable in your profile or when starting tmux
.
More information: http://vim.wikia.com/wiki/256_colors_setup_for_console_Vim

- 517

- 613
-
4Configuring tmux was enough for me; I did not need to set alias (though it probably wouldn't hurt). – anishpatel May 10 '17 at 06:33
-
1Configuring tmux alone works for me. The alias was not sufficient. – Harry Moreno Jun 23 '18 at 05:39
-
For me starting tmux with -u flag worked after setting the colors. So I created an alias as
alias tmux='tmux -u'
– Sathish Manohar Jul 30 '22 at 10:44
The newest version of ncurses ships with a tmux-256color terminfo entry (the FAQ does mention this). As an example, a benefit of using tmux-256color over screen-256color is that italics is properly rendered (screen doesn't support italics).
So if you are using tmux 2.6
or above, and have the latest ncurses package, the following will work as well:
set -g default-terminal "tmux-256color"
-
1
-
tmux 2.7 works with this setting on fedora 29 for vim solarized dark scheme without any other settings in
.bashrc
,.bash_profile
,.vimrc
) – Nick Dong Aug 30 '21 at 11:52
For people who have latest tmux, the .tmux.conf
option from the accepted answer should work.
I only want to add that you will probably need to restart tmux for the new configuration to take effect:
tmux kill-server && tmux
Interestingly, this isn't mentioned anywhere in the answers and took me a while to figure out.

- 301
-
9not knowing about the server restart gobbled up a few hours of my life. – Lmwangi Mar 28 '20 at 08:35
-
2I just created account here to tell you that, it saved my life. I was about to giveup on tmux. But this ans saved tmux in my life ;) I can't upvote :(. – Netro Apr 17 '20 at 07:00
-
1This just saved my life too after an hour of endless searching, felt like I was going insane. I'm going to propose this as an edit with credit to you in the top answer for visibility – craymichael Jul 01 '20 at 16:19
-
WHY IS THIS THE ONLY PLACE THAT SAYS YOU NEED TO KILL TMUX?!
Anyway, you saved me. Thank you!
– kurczynski Apr 18 '22 at 02:20
I could not explain why this works but it solved the problem for me.
~/.tmux.conf
set-option -g default-command bash

- 219
-
2
-
1Yes! This solution also worked on 18.04 and 20.04. Thank you very much. – Geppettvs D'Constanzo Jun 07 '20 at 17:35
-
Following lines in ~/.tmux.conf
worked for me --
set -g default-terminal "xterm-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc"
Tested on
- Tmux 2.7, Ubuntu 16.04,18.04
- Tmux 2.9, CentOS
- Tmux 3.0a, CentOS7

- 103

- 211
-
2Worked for me as well. Thanks! (Tmux 3.0a, Ubuntu 20.04, Terminal emulator:
Konsole
) – Jorge Morgado Nov 25 '21 at 06:49 -
3I've been searching for an hour and this was the only thing that worked for me. I'm running Arch with tmux v3.2a. – Ricky Nelson Feb 12 '22 at 01:13
-
Nothing on so many questions, on so many other blogs, etc. worked. The second line of this answer worked. I am on CentOS7, tmux3.0a. First line is not required for me. my default $TERM = xterm-256color. added my configuration to the test configurations in the answer. – Hamza Zubair May 19 '23 at 07:25
-
Really important note here if you're running an Ubuntu older than Bionic (18.04). If you're running tmux 2.1
or older, and you probably are, basically no advice you read online about tmux will work..for anything.
tmux -V
is an easy test for this. If you see 2.1
or older, you can build tmux from source, or you can add an unofficial repository. I updated my tmux with:
sudo add-apt-repository ppa:/hnakamur/tmux
sudo apt update
sudo apt upgrade
Personally, after upgrading to 2.6
, 1) my keys are working better, 2) online advice actually works, 3) my colors are not insane. Big improvement.
(Here's a link to the repository page, btw): https://launchpad.net/~hnakamur

- 319
This is my solution.... I edit my .bashrc file and adding this
if [ "$TERM" != "xterm-256color" ]; then
export TERM=xterm-256color
fi
Hopefully it works in yours

- 121
Feeling grateful for all other answers here giving me hints, but then it seems unnecessary to modify global TERM setting AND ~/.tmux.conf
.
I ended up using an alias to set the TERM only when I'm about to use tmux. Just add this one-liner at the end of your ~/.bashrc
(or whatever shell configuration file you use).
alias tmux='TERM=xterm-256color tmux'
That's it. Interestingly, after tmux launchs, the TERM would automatically be reset to "screen", but the colors work anyway. So I guess tmux would also be happy (for not messing up with its TERM environment?).

- 101
tmux -2
I had to do this in terminator and I was somewhat surprised. The-2
flag tells tmux to force the usage of 256 colors ... whether your terminal likes it or not ... dun dun dunnn :P – Dylan Oct 31 '15 at 14:27