tmux-plugins / tmux-cpu

Plug and play cpu percentage and icon indicator for Tmux.
MIT License
444 stars 69 forks source link

Add option to zero-prefix cpu frequency #30

Closed twilco closed 5 years ago

twilco commented 5 years ago

Thanks for this awesome plugin! One idea - it would be neat if you could prefix single digit CPU usage percentages with a zero - e.g. 05%. Currently, when my computer hovers between single-digit and double-digit percentage usages (e.g. 9% to 10%), the width of the status bar changes constantly, which is slightly distracting. Prefixing single-digit percentage usages with a zero would prevent this.

casperdcl commented 5 years ago

I sort of expected someone to complain after fixing #25 :)

I have no strong preference.

twilco commented 5 years ago

Ah, I actually agree with the point made in that issue. For anyone who wants this functionality, here's a janky little inline script I used:

set -g status-right '#{cpu_icon} #(cpu_perc="#{cpu_percentage}"; if [ $( wc -m <<< $cpu_perc ) -le 5 ]; then echo "0$cpu_perc"; else echo $cpu_perc; fi) | %I:%M %p '