2

When I log into my server, I'm usually greeted with a bunch of stats, like this:

Usual login; stats are shown

But if I enable byobu on login (through byobu-enable), I don't get to see the stats.
I'm immediately presented to byobu when I login:

Byobu login; no stats

Of course, the stats are output, but byobu immediately clears the screen.
Is there any way to see the stats while still having Byobu run at login?

3
  • This would be more of an Ubuntu server question... May 27, 2014 at 21:07
  • There are probably a couple of ways to solve this. Do you want to run a command in the byobu shell to see the server stats on demand? Do you want to see the stats automatically when byobu runs for the first time? Do you want to see it in every window created in an active byobu session? Do you want to see it when you reattach to a running byobu instance (not sure if this is possible)? May 29, 2014 at 22:11
  • I want to see stats when byobu starts for the first time, i.e. when a session is created. Reattaching to a previous section needn't produce any stats. May 30, 2014 at 20:25

2 Answers 2

5

The dynamic statistics that Ubuntu shows normally when you log in are contained in the file /run/motd.dynamic. This file is normally displayed when you log in, but as you correctly noticed, byobu clears the screen so it can't be seen. What you need to do is arrange for that file to be printed when the first byobu shell is started.

One way to accomplish this that works for me is to add the following shell snippet to your ~/.bashrc file. It will run for every new shell process, but the motd will only be shown once in the first tmux window that is started.

if [ -z "$_motd_listed" ]; then
  case "$TMUX_PANE" in
    %1) cat /run/motd.dynamic
        export _motd_listed=yes
        ;;
    *)  ;;
  esac
fi
2
  • Just what I was looking for. Works like a charm, thank you! But it won't work if Byobu is using screen as backend, I imagine we should check for $WINDOW (?) in that case. May 31, 2014 at 18:47
  • @jmendeth Yes, good point. I will test that out a little bit later and expand this answer to include both screen and tmux. Jun 2, 2014 at 14:55
1

Building on the accepted answer, I tested / added same condition for screen based session which has $WINDOW=0 for first screen so the combination for tmux and screen based sessions looks like this:

if [ -z "$_motd_listed" ]; then
  case "$TMUX_PANE" in
    %1) cat /run/motd.dynamic
        export _motd_listed=yes
        ;;
    *)  ;;
  esac
  case "$WINDOW" in
    0) cat /run/motd.dynamic
        export _motd_listed=yes
        ;;
    *)  ;;
  esac
fi
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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