One good example of this type of program is the screen plugin for vim; it checks the $STY environment variable to determine whether it is already inside screen or not. If that variable is already set, any screen command you execute will apply to that session.
On Fri, Dec 23, 2016 at 7:54 AM, Michael Parson <mpar...@bl.org> wrote: > On 2016-12-23 00:03, Jean Louis wrote: > >> Hello, >> >> Is there an option or possibility to programmatically open a new >> screen window? >> >> In particular, that program in one window, may find out its instance >> of screen and then to open new screen window with some other program >> running and switch focus to it? >> > > Some screen commands can send their output to stdout, others don't, but > there are ways to fake it. This will give you the session name for the > current screen session: > > > -- snippet -- > # get the sessionname for our current screen > screen -X sessionname > session=$(screen -X -Q lastmsg | awk '{print $NF'} | tr -d \') > -- end snippet -- > > You can then use this output to send commands to this screen session: > > -- snippet -- > # create a new screen window named "newwin" > screen -x ${sessionname} -X screen -t newwin > # select (change focus to) window "newwin" > screen -x ${sessionname} -X select newwin > # feed the new window a command-line > screen -x ${sessionname} -X at "newwin" stuff "echo hello world^M" > -- snippet -- > > -- > Michael Parson > Austin, TX > KF5LGQ > > > > _______________________________________________ > screen-users mailing list > screen-users@gnu.org > https://lists.gnu.org/mailman/listinfo/screen-users >
_______________________________________________ screen-users mailing list screen-users@gnu.org https://lists.gnu.org/mailman/listinfo/screen-users