You can put your commands in a file, e.g., myscreenrc
, like this:
screen command1
screen command2
screen command3
and then execute screen
with the -c
option followed by the name of that file, e.g.,
screen -c myscreenrc
UPDATE
in reponse to the updated question. The commands I used for testing were screen vim foo
and screen vim bar
, so I didn't see the screen-closing problem. The following solves the screen-closing problem, but it seems a bit of a kludge.
screen bash -c 'ls foo; exec bash -i'
screen bash -c 'ls bar; exec bash -i'
ls
was just a convenient command for testing this problem.
UPDATE #2
Another approach would be to start the command from the shell's rc file rather than from screen's rc file. It requires another file for each command, though. For example, to run top
in a screen
window such that quitting top
will return you to a bash
prompt in that same window, create a file, call it runtop
, that contains the following:
. ~/.bashrc
top
Then put this line in the file we're calling screenrc
:
screen bash --rcfile ~/runtop -i
and start screen
as
screen -c screenrc
in case anyone need the answer,
after google around, I found the solution below.
the short answer is : ctrl-A ]
A longer answer:
to save the text into a file, open a text editor,
such as vim, set it to paste mode ( :set paste ), then input mode ( i ),
then paste it from byobu: ctrl-A ]
done!
Best Answer
You could make a bind to create such a keybinding in your screenrc, because there is none.
Depending on how you wanted to implement it (is it for a named screen whose name is known?), the following screen functions could be useful to you:
copy
(C-a esc
/C-a [
) to make your copy of the current windowwritebuf
(C-a >
) to write/tmp/screen-exchange
readbuf
(C-a <
) to read in the other /tmp/screen-exchangepaste .
(C-a ]
/C-a C-]
) to write the paste on the other windowat [identifier][#|*|%] command [args ...]
to make other windows process the two former commands from the specified original window, without leaving it (through a keybind or directly at the screen commandlineC-a :
).