Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to have bash script run by screen every time when i attach ( or detach ( session.

Is there any way to configure screen to do that?

share|improve this question

If you have the scripts, then you can do that. But screen by itself does not have hooks to be called on reattach or detach. There is no event handler system accessible to the user.

However for detach, you might be able to exec commands in on keyboard sequences. For example, bind ^D exec ${HOME}/bin/; and then have ~/bin/ do what you need and force a detach on the screen session. You might also be able to do this with stuff.

share|improve this answer

Your Answer


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.