Linux – Problems with tmux, mutt, and terminal colors

linuxmuttterminaltmux

If I start mutt in a tmux session like this:

$ tmux new-session -s mutt mutt

Mutt complains:

Error in /home/lars/.mutt/colors, line 20: 230: color not supported by term
Error in /home/lars/.mutt/colors, line 26: 244: color not supported by term

But if I start tmux like this, without a command:

$ tmux new-session -s mutt

And then inside the tmux session start mutt:

$ exec mutt

It works without a problem. In both cases, TERM inside the tmux session is set to screen-256color. I don't see any functional difference between these two cases, so I'm confused. For what it's worth, the -2 option to tmux ("Force tmux to assume the terminal supports 256 colours") doesn't seem to have any effect on this behavior.

Has anyone seen this behavior? Do you know what causes it, and how to resolve it?

Best Answer

tmux new-session -s mutt followed by echo $TERM results in xterm-256color

however,

tmux new-session -s mutt 'echo $TERM && sleep 10'

yields screen. To get around this, try:

tmux new-session -s mutt 'TERM=xterm-256color; echo $TERM && sleep 10'

to see the correct setting, and to make mutt work:

tmux new-session -s mutt 'TERM=xterm-256color mutt'
Related Question