stevendesu stevendesu - 3 months ago 13
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

.tmux.conf
file:

set -g status-right "#(~/load.sh)"


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
    (B[m

  2. The MEM section... should exist. The entire
    [| ]
    has turned into a
    y>
    -- 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?

Answer

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!
Comments