Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Can I automatically execute a command on reattaching a detached byobu (screen or tmux) session?

Every time I login, /etc/motd is displayed. Since I hardly ever log out and in, I'd like to have the same functionality when reattaching to my detached session. This could be a simple cat /etc/motd kind of autostart.

share|improve this question
    
Where it displays that? If you're running something (editor, for example) on your screen/byobu/..., how it should display contents of motd? –  Olli Feb 6 at 18:23
    
I guess you're right. Maybe that task would have to be done by the shell I'm running. –  user245396 Feb 6 at 18:56
    
So you want that to happen every time you open a new shell? For example, new tab on screen, or before screen is reattached? (Something like "press enter to continue") –  Olli Feb 6 at 18:58
    
Before screen is reattached would do the job. –  user245396 Feb 6 at 19:11

1 Answer 1

I found a way to execute commands, not on reattaching but on idle: first I changed the byobu backend to screen, then I created a .screenrc in ~/.byobu containing

blankerprg  zsh -c "while true; do run-parts --lsbsysinit /etc/update-motd.d; sleep 30; clear; done"
idle        600 blanker

That uses screen's screensaver functionality to display text I would normally only see on login.

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.