[Top][All Lists]

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

Re: How to programmatically open new screen window?

From: Michael Parson
Subject: Re: How to programmatically open new screen window?
Date: Fri, 23 Dec 2016 09:54:04 -0600
User-agent: Roundcube Webmail/1.1.4

On 2016-12-23 00:03, Jean Louis wrote:

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

reply via email to

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