[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatically start/attach to a multi-user Screen session, for new

From: Ryan Lynch
Subject: Re: Automatically start/attach to a multi-user Screen session, for new BASH shell instances.
Date: Fri, 9 Oct 2009 19:34:11 -0400

(CCing the Screen users list, in case anybody else is interested in this, too.)

On Tue, Oct 6, 2009 at 18:19, Ryan Lynch <address@hidden> wrote:
> When I've cleaned it up enough for human consumption, I'll post a copy
> of the whole script.

I've attached a copy of the script I'm currently using to auto-join
Screen when I start a shell.  I call it 'Porch'.  Here's a pretty
comprehensive feature list:

 * All new BASH instances will join the same screen session.  If it
doesn't exist, the first shell will start it, and then join.
 * All shells join the session co-operatively (the '-m' flag), so that
each new joiner doesn't kick the rest off.
 * Auto-exits the shell when Screen terminates, or when the display detaches.
 * Allows a short timeout, with a PRESS ANY KEY TO CANCEL type message
displayed, for the user to cancel joining the session or exiting the
shell when the session terminates/detaches.
 * If you manually cancel out of joining a Screen session, it
remembers, and exports a flag to sub-shells that supresses the
auto-joining behavior.
 * Ignores non-interactive shells.
 * Ignores already-'Screened' shells. (With an exception, see below.)
 * Inserts the Screen session name into your "hardstatus" line,
automatically, by modifying BASH's $PROMPT_COMMAND.  (This normally
isn't possible because Screen's own 'hardstatus string ...' command
doesn't support an escape for the session name.)

There are some broken bits that I haven't had time to finish
debugging, though.  I'm trying to make it nest properly, so that you
can join a local Screen session, and then run an SSH client from
within the local session that connects to a remote host, and then join
a remote Screen session.  (This requires installing the script on both
the local and remote hosts, of course.)

But for now, it works well enough to be useful.  I never have to
regret not starting a Screen session, earlier.

I'm making this available as-is, in case anyone wants to use it, copy
it, or just get ideas from it.  I would appreciate any suggestions,
feedback, or patches, too.

To use it, save a copy locally (I stick it in '/usr/bin'), and source
it at the end of your .bashrc, like this:

. /usrbin/


Description: Bourne shell script

reply via email to

[Prev in Thread] Current Thread [Next in Thread]