How do you filter the output of a constantly updating bash command so that text is overlayed on top of the output?

I'm using tmux to show multiple htop processes across numerous servers. Unfortunately tmux doesn't make it easy to label each pane, so I want to overlay the name of the server somewhere in the output. I don't care if it obscures a small part of the output.


2 Answers 2


you can run top in batch mode (see man top) and instead loop it with watch. So f.ex. :

watch "hostname; top -b -n 1"
  • 1
    Maybe consider using watch -t so that the header isn't shown. Might make it easier on the eyes.
    – Terrance
    Commented Dec 16, 2017 at 0:35
  • Sorry, I meant to say "htop" in my post. Your solution comes close to working with htop to, by replacing the top command with echo q | htop. However, it looks like watch doesn't interpret color codes correctly, resulting in a lot of visible escape characters mangling the output.
    – Cerin
    Commented Dec 16, 2017 at 11:18

tmux from 2.3 allows you to set a title in each pane border. Enable it in your ~/.tmux.conf with:

set -g pane-border-format "#{pane_index} #{pane_title}"
set -g pane-border-status bottom

Then before running your htop command in each pane add a printf command in that pane that will send the appropriate escape sequence to dynamically set the pane title:

printf '\033]2;%s\033\\' 'remotehost'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .