-1

I'm using Mac OSX Yosemite, and I use istats to get CPU temperatures: istats_output

I wanted to put my CPU temperature in my tmux status bar, so I made my tmux config the following:

tmux_conf

As you can see, when I ran :source-file ~/.tmux.conf, tmux is printing the ANSI codes as text, rather than rendering the colors. How do I make tmux render the color codes, rather than printing them out as text?

1

I solved the problem by writing a simple python script to replace the ANSI codes with tmux color variables.

#!/usr/local/bin/python

s = raw_input("")

s = s.replace('\x1b[32m', '#[fg=colour10]')
s = s.replace('\x1b[93m', '#[fg=colour11]')
s = s.replace('\x1b[0m', '#[fg=colour255]')

print s

I just pipe the output to the script: istats | grep "CPU temp" | ansi2tmuxcolors.py

0

I generalized Subliminalmau5 answer by writing a separate shell with

sed -r 's,\x1b\[38;5;([0-9]+)m,#[fg=colour\1],g'|sed -r 's,\x1b\[1m,#[bold],g'|sed -r 's,\x1b\[0m,#[default],g'

which translated all 256 colors of ANSI to tmux.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.