Re: How to programmatically open new screen window?
Michael Parson <[email protected]>
| Newsgroups | gmane.comp.gnu.screen.user |
|---|---|
| Organization | BL dot ORG |
| Message-ID | <[email protected]> |
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