tmux-plugin-sysstat icon indicating copy to clipboard operation
tmux-plugin-sysstat copied to clipboard

Pad percentage outputs

Open sdfg2 opened this issue 6 years ago • 5 comments

This is just a quick one - I love this wee plugin!

How would I go about padding the CPU and MEM % outputs? I'd like them to always take up the same amount of space.

sdfg2 avatar Sep 07 '18 15:09 sdfg2

+1 that would be nice. Any updates?

madnight avatar Jan 16 '19 22:01 madnight

This should fix the problem (more or less like #17, but applied manually after the installation):

SYSSTAT_SCRIPTS_DIR="$HOME"/.tmux/plugins/tmux-plugin-sysstat/scripts
cd "$SYSSTAT_SCRIPTS_DIR"
sed -i 's/%.[01]f%%/%2.0f%%/g' {cpu,mem,swap}.sh

SYSSTAT_SCRIPTS_DIR is where the files cpu.sh, mem.sh and swap.sh are located, it is usually:

~/.tmux/plugins/tmux-plugin-sysstat/scripts

or

~/.config/tmux/plugins/tmux-plugin-sysstat/scripts

Cheers

LFd3v avatar Oct 28 '23 23:10 LFd3v

Thanks for taking a look. I tried it out and it works. The only downside that I see for this fix is that if CPU usage is low (less than 10%) the script is still reserving a 2 character space even if you remove the floating point, so you end up with Original: "CPU: 5.5%" Modified: "CPU: 5%" (Ideally I think it should be "CPU: 5%", without the extra space) But it's a really particular use case.

tuv7041 avatar Oct 29 '23 13:10 tuv7041

@tuv7041 Actually the padding is intentional (as requested in this issue): the CPU usage percentage value varies from X to XX, it causes the status widget to change the width a lot ("CPU" moves its position in the status bar from time to time when this happens), what I think is very distracting. The padding avoids this.

Cheers

LFd3v avatar Oct 29 '23 14:10 LFd3v

oh, sorry, my bad. I commented here a long time ago and forgot about the context (I was more focused on the decimal than the padding). Thanks again for fixing it.

tuv7041 avatar Oct 29 '23 16:10 tuv7041