I'm trying to add nVidia GPU utilization to my byobu-tmux status line. I've installed gpustat which returns
~$ gpustat
myhost Mon Aug 19 17:26:51 2019 410.48
GeForce GTX 1080 Ti | 22'C, 0 % | 0 / 11178 MB |
[1] GeForce GTX 1080 Ti | 41'C, 0 % | 0 / 11175 MB |
then I wrote a text processor saved to ~/.byobu/bin/2_gpu as suggested in the byobu web page for custom status.
~$ cat .byobu/bin/2_gpu
#!/bin/sh
echo "$(gpustat | tail -n+1 | sed -nr "s/\[[0-9]\].+([0-9]+)\s\%.*$/\1%/p" | tr [:space:] ',' | head -c-1)"
from the bash shell that seems to work; whether the shebang is sh or bash doesn't seem to matter, it works fine:
~$ .byobu/bin/2_gpu
0%,0%
however I can't get that text onto the byobu-tmux status line. A simpler custom status works fine, but there's some problem escaping the quotes and/or '$' in the regex argument to the sed command. I'm not sure why echo is even needed, but removing the echo "$(...)"
doesn't help, nor does adding backslashes on the inner double-quote and '$' characters.
Asked by WiringHarness
(151 rep)
Aug 20, 2019, 01:00 AM
Last activity: Jun 19, 2024, 09:07 PM
Last activity: Jun 19, 2024, 09:07 PM