stevendesu stevendesu - 7 months ago 29
Bash Question

.tmux.conf color codes causing strange output

Follow-up to: Colored text printing spaces in shell script

I have a script I wrote (with some help from @Barmar) which displays my current CPU and memory load visually. The output looks like so:

output from SH

I then put the following into my


set -g status-right "#(~/"

I reload my tmux config and get the following output in the bottom-right:

output from tmux

There are two issues:

  1. The CPU section should contain 11 characters: a "clear color code" character (
    tput sgr0
    ) and 10 spaces. Instead it contains

  2. The MEM section... should exist. The entire
    [| ]
    has turned into a
    -- I don't even know how the square bracket is missing, that should get printed before any color codes or weird control characters

Can tmux status bars simply not contain color?


tmux status bars don't use ANSI escape codes, they use the same color code format as other things in tmux. You want something more like (assuming 256-color mode):

#[fg=colour28 bg=colour250]Hello World!