Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it possible to get GNU Screen to display the output of an arbitrary command, e.g. who | wc -l, in the status bar, refreshing it, say, every minute?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Yes you can using the backtick feature. Backtick

You put a line in your screenrc file:

backtick 1 0 5 /bin/date

If I understand correctly, it means backtick id 1, which runs command /bin/date, produces output valid for 0 seconds and the caption/hardstatus should be updated every 5 seconds.

Now, you can use the string $1` inside your hardstatus for substitution, eg

hardstatus alwayslastline "date output: $1`"

In your case, I think you'll have to write a script. For example, $HOME/my_script.sh:

#!/bin/bash
who | wc -l

In your ~/.screenrc:

backtick 1 0 60 $HOME/my_script.sh
hardstatus alwayslastline "who|wc -l output: $1`"

Obviously you won't want exactly that, but just add $1` to whatever else you have. Note that your script output can't include string escapes for screen to expand, e.g. if your script is echo "%{bg}blue on green%{dd}" it won't be coloured, you'll just see ${bg} and ${dd} in your status line.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.