I'm attempting to show the hostname above htop
output, in order to better identify which server its monitoring. I haven't found a good way to do this, but the closest I've gotten is with the command:
watch --color -t "hostname; echo q | htop"
Unfortunately, due to how watch
interprets special characters, it renders slightly mangled output like:
It looks like watch
is corrupting the newline, tab and carriage return characters. I think I could potentially correct this via a Python or Bash script, but I'm having trouble making sense of the escape syntax. All the special characters seem to be rendered as "(B" followed by 0 to 4 numbers. However, for characters that should be the same, such as what should be new lines after each process row, the escaped character uses a completely different code. For example "(B3263" and "(B3264".
How do I interpret these numbers and convert them back to the correct characters while preserving the color?