Tmux Colors Not Working

I have a bit of an odd issue as far as I can tell. When I use tmux I don't get color within the terminal (all text is white, even for things like ls), but my colors work perfectly for vim and other things like that.

In my .tmux.conf file I have the line set -g default-terminal "screen-256color", which is what most people say solved their problems. I also tried starting tmux by typing tmux -2, but that doesn't change anything.

I'm kind of at a loss at this point, so thanks in advance for any help you can offer!

OS: Ubuntu 16.04

Tmux Version: 2.1


I can help you solve the symptom, but not the root of the problem. The design of the prompt is configured in the variable PS1.

Outside tmux, this is the value:

$ echo ${PS1} # outside tmux
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$

This is the value inside tmux:

$ echo ${PS1} # outside tmux
${debian_chroot:+($debian_chroot)}\u@\h:\w\$

to fix the problem, you can run this command inside tmux, and the prompt will immediately look normal for the current window:

PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

edit: I solved it by adding the following line to ~/.tmux.conf

set -g default-terminal "screen-256color"

This is a bit of an old one. I resolved this issue by creating a .bash_profile file and sourcing my .bashrc file.

To do this, add source ~/.bashrc to your .bash_profile file.

The problem in my case was due to my bashrc settings not being sourced via tmux. Tmux runs as a login shell so it looks for a .bash_profile file or a .bash_login file. My colours were being set in my .bashrc file.