Automatically reattach to a screen session after logging in via ssh

The following code when added to your .bashrc file will, after logging in via ssh, look for any unattached screen sessions and automatically attach to the first one found. If only attached sessions are found then a list of these will be outputted to std out. Finally, If there are no screen sessions running at all then a new screen session will be created.

Optionally adding the following will alter your prompt to let you easily know which window within a screen session you are currently in.

NOTE: screen is not always installed by default so you may need to grab it before using the above. It should be available via your distros package manager.

Добавить комментарий