Do not clear a split screen region when one command completes
Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
I run some commands in parallel and I want to see their last output after all of them complete (in the scrollback of my terminal emulator). Here's my test script test.screen
:
#
screen -t A sh -c 'echo important info && sleep 2'
split
focus
#
screen -t B sh -c 'echo another important info && sleep 5'
The launch command:
$ screen -c test.screen
Output:
[screen is terminating]
[il@reallin ~]$
--
another important info
1 B
One problem is: when the first sleep 2
completes, the printed message important info
is erased. If I add zombie kr
at the beginning, then screen does not exit at all. As a workaround the caller can wait for all screen processes to exit and then issue -X quit
The other problem: the caret does not move to the bottom when screen
exits and the shell prompt overwrites some data. The workaround is to echo
$LINES times.
gnu-screen
add a comment |Â
up vote
-1
down vote
favorite
I run some commands in parallel and I want to see their last output after all of them complete (in the scrollback of my terminal emulator). Here's my test script test.screen
:
#
screen -t A sh -c 'echo important info && sleep 2'
split
focus
#
screen -t B sh -c 'echo another important info && sleep 5'
The launch command:
$ screen -c test.screen
Output:
[screen is terminating]
[il@reallin ~]$
--
another important info
1 B
One problem is: when the first sleep 2
completes, the printed message important info
is erased. If I add zombie kr
at the beginning, then screen does not exit at all. As a workaround the caller can wait for all screen processes to exit and then issue -X quit
The other problem: the caret does not move to the bottom when screen
exits and the shell prompt overwrites some data. The workaround is to echo
$LINES times.
gnu-screen
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I run some commands in parallel and I want to see their last output after all of them complete (in the scrollback of my terminal emulator). Here's my test script test.screen
:
#
screen -t A sh -c 'echo important info && sleep 2'
split
focus
#
screen -t B sh -c 'echo another important info && sleep 5'
The launch command:
$ screen -c test.screen
Output:
[screen is terminating]
[il@reallin ~]$
--
another important info
1 B
One problem is: when the first sleep 2
completes, the printed message important info
is erased. If I add zombie kr
at the beginning, then screen does not exit at all. As a workaround the caller can wait for all screen processes to exit and then issue -X quit
The other problem: the caret does not move to the bottom when screen
exits and the shell prompt overwrites some data. The workaround is to echo
$LINES times.
gnu-screen
I run some commands in parallel and I want to see their last output after all of them complete (in the scrollback of my terminal emulator). Here's my test script test.screen
:
#
screen -t A sh -c 'echo important info && sleep 2'
split
focus
#
screen -t B sh -c 'echo another important info && sleep 5'
The launch command:
$ screen -c test.screen
Output:
[screen is terminating]
[il@reallin ~]$
--
another important info
1 B
One problem is: when the first sleep 2
completes, the printed message important info
is erased. If I add zombie kr
at the beginning, then screen does not exit at all. As a workaround the caller can wait for all screen processes to exit and then issue -X quit
The other problem: the caret does not move to the bottom when screen
exits and the shell prompt overwrites some data. The workaround is to echo
$LINES times.
gnu-screen
edited Oct 14 '17 at 14:42
asked Oct 14 '17 at 11:19
basin
6881721
6881721
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
If you do not want the screen to clear when exiting "screen", you should choose (or modify) a terminal description which does not switch to the alternate screen. That is the TERM
value outside screen
.
With xterm (and a few others such as PuTTY) you can configure the terminal to prevent using the alternate screen, but for most terminals which copy xterm's alternate screen feature, this is hard-coded, not configurable. So the terminal description is the place to start.
ncurses provides a terminal description "xterm1" which has the alternate screen suppressed (and seeing that it is in Debian, it's probably in derived distributions such as Ubuntu). For other systems, it depends. Here's a difference from infocmp:
comparing xterm1 to xterm.
comparing booleans.
comparing numbers.
comparing strings.
rmcup: NULL, 'E[?1049l'.
smcup: NULL, 'E[?1049h'.
The "screen" program also has its own variant of the alternate screen which is normally off:
altscreen on|off
If set to on, "alternate screen" support is enabled in virtual termiâÂÂ
nals, just like in xterm. Initial setting is `off'.
Further reading:
- Why doesn't the screen clear when running vi?
We're talking not about the altscreen feature of xterm and likes, but about clearing the screen's window.
â basin
Oct 14 '17 at 12:00
They are not separable, because the clearing happens using the outer terminal description. I pointed that out in the first sentence.
â Thomas Dickey
Oct 14 '17 at 13:59
addingaltscreen off
at the beginning of the script does not prevent clearing that region of the screen
â basin
Oct 14 '17 at 14:28
Sure: clearing the terminal on exit fromscreen
is controlled by the outer terminal description. Inside,screen
simulates its own alternate screen feature.
â Thomas Dickey
Oct 14 '17 at 14:32
I cannot use your answer
â basin
Oct 14 '17 at 14:41
add a comment |Â
up vote
-1
down vote
accepted
There's no good solution for a split screen region being cleared: zombie windows prevent screen from exiting. I had to add additional synchronization between the windows and the caller script and when they all die, I call screen -X quit
explicitly.
The altscreen
command had nothing to do with this. The cursor didn't move to the bottom, because my default /etc/screenrc
was half-working: the host terminal altscreen feature was used, but the altscreen wasn't cleared before switching back. To make it work by default I copied /etc/screenrc
from CentOS 7
and for my case I disabled the feature completely with termcapinfo * ti=:te=
.
test.sh:
#!/bin/bash
# set -e
if [ "a" = "$1" ]; then
# decrement file name towards zero, then kill screen
set -e
a=-1
cd "$COUNTERDIR"
while true; do
for old in *; do
new=$((old + a))
done
[ 0 -eq "$a" ] || 2>/dev/null mv ./$old ./$new && break
done
if [ 0 -eq "$new" ]; then
screen -X quit
fi
exit
fi
NWINDOWS=2
COUNTERDIR=`mktemp -d`
touch "$COUNTERDIR/$NWINDOWS"
export COUNTERDIR
screen -c test.screen
rm -rf "$COUNTERDIR"
test.screen:
# do not use host terminal altscreen feature
termcapinfo * ti=:te=
# windows stay after command terminates
zombie kr
screen -t A sh -c 'for ((i=0; i<100; i++)); do echo important info $i; done && sleep 5; ./test.sh a'
split
focus
screen -t B sh -c 'for ((i=0; i<100; i++)); do echo another important info $i; done && sleep 2; ./test.sh a'
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
If you do not want the screen to clear when exiting "screen", you should choose (or modify) a terminal description which does not switch to the alternate screen. That is the TERM
value outside screen
.
With xterm (and a few others such as PuTTY) you can configure the terminal to prevent using the alternate screen, but for most terminals which copy xterm's alternate screen feature, this is hard-coded, not configurable. So the terminal description is the place to start.
ncurses provides a terminal description "xterm1" which has the alternate screen suppressed (and seeing that it is in Debian, it's probably in derived distributions such as Ubuntu). For other systems, it depends. Here's a difference from infocmp:
comparing xterm1 to xterm.
comparing booleans.
comparing numbers.
comparing strings.
rmcup: NULL, 'E[?1049l'.
smcup: NULL, 'E[?1049h'.
The "screen" program also has its own variant of the alternate screen which is normally off:
altscreen on|off
If set to on, "alternate screen" support is enabled in virtual termiâÂÂ
nals, just like in xterm. Initial setting is `off'.
Further reading:
- Why doesn't the screen clear when running vi?
We're talking not about the altscreen feature of xterm and likes, but about clearing the screen's window.
â basin
Oct 14 '17 at 12:00
They are not separable, because the clearing happens using the outer terminal description. I pointed that out in the first sentence.
â Thomas Dickey
Oct 14 '17 at 13:59
addingaltscreen off
at the beginning of the script does not prevent clearing that region of the screen
â basin
Oct 14 '17 at 14:28
Sure: clearing the terminal on exit fromscreen
is controlled by the outer terminal description. Inside,screen
simulates its own alternate screen feature.
â Thomas Dickey
Oct 14 '17 at 14:32
I cannot use your answer
â basin
Oct 14 '17 at 14:41
add a comment |Â
up vote
0
down vote
If you do not want the screen to clear when exiting "screen", you should choose (or modify) a terminal description which does not switch to the alternate screen. That is the TERM
value outside screen
.
With xterm (and a few others such as PuTTY) you can configure the terminal to prevent using the alternate screen, but for most terminals which copy xterm's alternate screen feature, this is hard-coded, not configurable. So the terminal description is the place to start.
ncurses provides a terminal description "xterm1" which has the alternate screen suppressed (and seeing that it is in Debian, it's probably in derived distributions such as Ubuntu). For other systems, it depends. Here's a difference from infocmp:
comparing xterm1 to xterm.
comparing booleans.
comparing numbers.
comparing strings.
rmcup: NULL, 'E[?1049l'.
smcup: NULL, 'E[?1049h'.
The "screen" program also has its own variant of the alternate screen which is normally off:
altscreen on|off
If set to on, "alternate screen" support is enabled in virtual termiâÂÂ
nals, just like in xterm. Initial setting is `off'.
Further reading:
- Why doesn't the screen clear when running vi?
We're talking not about the altscreen feature of xterm and likes, but about clearing the screen's window.
â basin
Oct 14 '17 at 12:00
They are not separable, because the clearing happens using the outer terminal description. I pointed that out in the first sentence.
â Thomas Dickey
Oct 14 '17 at 13:59
addingaltscreen off
at the beginning of the script does not prevent clearing that region of the screen
â basin
Oct 14 '17 at 14:28
Sure: clearing the terminal on exit fromscreen
is controlled by the outer terminal description. Inside,screen
simulates its own alternate screen feature.
â Thomas Dickey
Oct 14 '17 at 14:32
I cannot use your answer
â basin
Oct 14 '17 at 14:41
add a comment |Â
up vote
0
down vote
up vote
0
down vote
If you do not want the screen to clear when exiting "screen", you should choose (or modify) a terminal description which does not switch to the alternate screen. That is the TERM
value outside screen
.
With xterm (and a few others such as PuTTY) you can configure the terminal to prevent using the alternate screen, but for most terminals which copy xterm's alternate screen feature, this is hard-coded, not configurable. So the terminal description is the place to start.
ncurses provides a terminal description "xterm1" which has the alternate screen suppressed (and seeing that it is in Debian, it's probably in derived distributions such as Ubuntu). For other systems, it depends. Here's a difference from infocmp:
comparing xterm1 to xterm.
comparing booleans.
comparing numbers.
comparing strings.
rmcup: NULL, 'E[?1049l'.
smcup: NULL, 'E[?1049h'.
The "screen" program also has its own variant of the alternate screen which is normally off:
altscreen on|off
If set to on, "alternate screen" support is enabled in virtual termiâÂÂ
nals, just like in xterm. Initial setting is `off'.
Further reading:
- Why doesn't the screen clear when running vi?
If you do not want the screen to clear when exiting "screen", you should choose (or modify) a terminal description which does not switch to the alternate screen. That is the TERM
value outside screen
.
With xterm (and a few others such as PuTTY) you can configure the terminal to prevent using the alternate screen, but for most terminals which copy xterm's alternate screen feature, this is hard-coded, not configurable. So the terminal description is the place to start.
ncurses provides a terminal description "xterm1" which has the alternate screen suppressed (and seeing that it is in Debian, it's probably in derived distributions such as Ubuntu). For other systems, it depends. Here's a difference from infocmp:
comparing xterm1 to xterm.
comparing booleans.
comparing numbers.
comparing strings.
rmcup: NULL, 'E[?1049l'.
smcup: NULL, 'E[?1049h'.
The "screen" program also has its own variant of the alternate screen which is normally off:
altscreen on|off
If set to on, "alternate screen" support is enabled in virtual termiâÂÂ
nals, just like in xterm. Initial setting is `off'.
Further reading:
- Why doesn't the screen clear when running vi?
answered Oct 14 '17 at 11:52
Thomas Dickey
49.9k586155
49.9k586155
We're talking not about the altscreen feature of xterm and likes, but about clearing the screen's window.
â basin
Oct 14 '17 at 12:00
They are not separable, because the clearing happens using the outer terminal description. I pointed that out in the first sentence.
â Thomas Dickey
Oct 14 '17 at 13:59
addingaltscreen off
at the beginning of the script does not prevent clearing that region of the screen
â basin
Oct 14 '17 at 14:28
Sure: clearing the terminal on exit fromscreen
is controlled by the outer terminal description. Inside,screen
simulates its own alternate screen feature.
â Thomas Dickey
Oct 14 '17 at 14:32
I cannot use your answer
â basin
Oct 14 '17 at 14:41
add a comment |Â
We're talking not about the altscreen feature of xterm and likes, but about clearing the screen's window.
â basin
Oct 14 '17 at 12:00
They are not separable, because the clearing happens using the outer terminal description. I pointed that out in the first sentence.
â Thomas Dickey
Oct 14 '17 at 13:59
addingaltscreen off
at the beginning of the script does not prevent clearing that region of the screen
â basin
Oct 14 '17 at 14:28
Sure: clearing the terminal on exit fromscreen
is controlled by the outer terminal description. Inside,screen
simulates its own alternate screen feature.
â Thomas Dickey
Oct 14 '17 at 14:32
I cannot use your answer
â basin
Oct 14 '17 at 14:41
We're talking not about the altscreen feature of xterm and likes, but about clearing the screen's window.
â basin
Oct 14 '17 at 12:00
We're talking not about the altscreen feature of xterm and likes, but about clearing the screen's window.
â basin
Oct 14 '17 at 12:00
They are not separable, because the clearing happens using the outer terminal description. I pointed that out in the first sentence.
â Thomas Dickey
Oct 14 '17 at 13:59
They are not separable, because the clearing happens using the outer terminal description. I pointed that out in the first sentence.
â Thomas Dickey
Oct 14 '17 at 13:59
adding
altscreen off
at the beginning of the script does not prevent clearing that region of the screenâ basin
Oct 14 '17 at 14:28
adding
altscreen off
at the beginning of the script does not prevent clearing that region of the screenâ basin
Oct 14 '17 at 14:28
Sure: clearing the terminal on exit from
screen
is controlled by the outer terminal description. Inside, screen
simulates its own alternate screen feature.â Thomas Dickey
Oct 14 '17 at 14:32
Sure: clearing the terminal on exit from
screen
is controlled by the outer terminal description. Inside, screen
simulates its own alternate screen feature.â Thomas Dickey
Oct 14 '17 at 14:32
I cannot use your answer
â basin
Oct 14 '17 at 14:41
I cannot use your answer
â basin
Oct 14 '17 at 14:41
add a comment |Â
up vote
-1
down vote
accepted
There's no good solution for a split screen region being cleared: zombie windows prevent screen from exiting. I had to add additional synchronization between the windows and the caller script and when they all die, I call screen -X quit
explicitly.
The altscreen
command had nothing to do with this. The cursor didn't move to the bottom, because my default /etc/screenrc
was half-working: the host terminal altscreen feature was used, but the altscreen wasn't cleared before switching back. To make it work by default I copied /etc/screenrc
from CentOS 7
and for my case I disabled the feature completely with termcapinfo * ti=:te=
.
test.sh:
#!/bin/bash
# set -e
if [ "a" = "$1" ]; then
# decrement file name towards zero, then kill screen
set -e
a=-1
cd "$COUNTERDIR"
while true; do
for old in *; do
new=$((old + a))
done
[ 0 -eq "$a" ] || 2>/dev/null mv ./$old ./$new && break
done
if [ 0 -eq "$new" ]; then
screen -X quit
fi
exit
fi
NWINDOWS=2
COUNTERDIR=`mktemp -d`
touch "$COUNTERDIR/$NWINDOWS"
export COUNTERDIR
screen -c test.screen
rm -rf "$COUNTERDIR"
test.screen:
# do not use host terminal altscreen feature
termcapinfo * ti=:te=
# windows stay after command terminates
zombie kr
screen -t A sh -c 'for ((i=0; i<100; i++)); do echo important info $i; done && sleep 5; ./test.sh a'
split
focus
screen -t B sh -c 'for ((i=0; i<100; i++)); do echo another important info $i; done && sleep 2; ./test.sh a'
add a comment |Â
up vote
-1
down vote
accepted
There's no good solution for a split screen region being cleared: zombie windows prevent screen from exiting. I had to add additional synchronization between the windows and the caller script and when they all die, I call screen -X quit
explicitly.
The altscreen
command had nothing to do with this. The cursor didn't move to the bottom, because my default /etc/screenrc
was half-working: the host terminal altscreen feature was used, but the altscreen wasn't cleared before switching back. To make it work by default I copied /etc/screenrc
from CentOS 7
and for my case I disabled the feature completely with termcapinfo * ti=:te=
.
test.sh:
#!/bin/bash
# set -e
if [ "a" = "$1" ]; then
# decrement file name towards zero, then kill screen
set -e
a=-1
cd "$COUNTERDIR"
while true; do
for old in *; do
new=$((old + a))
done
[ 0 -eq "$a" ] || 2>/dev/null mv ./$old ./$new && break
done
if [ 0 -eq "$new" ]; then
screen -X quit
fi
exit
fi
NWINDOWS=2
COUNTERDIR=`mktemp -d`
touch "$COUNTERDIR/$NWINDOWS"
export COUNTERDIR
screen -c test.screen
rm -rf "$COUNTERDIR"
test.screen:
# do not use host terminal altscreen feature
termcapinfo * ti=:te=
# windows stay after command terminates
zombie kr
screen -t A sh -c 'for ((i=0; i<100; i++)); do echo important info $i; done && sleep 5; ./test.sh a'
split
focus
screen -t B sh -c 'for ((i=0; i<100; i++)); do echo another important info $i; done && sleep 2; ./test.sh a'
add a comment |Â
up vote
-1
down vote
accepted
up vote
-1
down vote
accepted
There's no good solution for a split screen region being cleared: zombie windows prevent screen from exiting. I had to add additional synchronization between the windows and the caller script and when they all die, I call screen -X quit
explicitly.
The altscreen
command had nothing to do with this. The cursor didn't move to the bottom, because my default /etc/screenrc
was half-working: the host terminal altscreen feature was used, but the altscreen wasn't cleared before switching back. To make it work by default I copied /etc/screenrc
from CentOS 7
and for my case I disabled the feature completely with termcapinfo * ti=:te=
.
test.sh:
#!/bin/bash
# set -e
if [ "a" = "$1" ]; then
# decrement file name towards zero, then kill screen
set -e
a=-1
cd "$COUNTERDIR"
while true; do
for old in *; do
new=$((old + a))
done
[ 0 -eq "$a" ] || 2>/dev/null mv ./$old ./$new && break
done
if [ 0 -eq "$new" ]; then
screen -X quit
fi
exit
fi
NWINDOWS=2
COUNTERDIR=`mktemp -d`
touch "$COUNTERDIR/$NWINDOWS"
export COUNTERDIR
screen -c test.screen
rm -rf "$COUNTERDIR"
test.screen:
# do not use host terminal altscreen feature
termcapinfo * ti=:te=
# windows stay after command terminates
zombie kr
screen -t A sh -c 'for ((i=0; i<100; i++)); do echo important info $i; done && sleep 5; ./test.sh a'
split
focus
screen -t B sh -c 'for ((i=0; i<100; i++)); do echo another important info $i; done && sleep 2; ./test.sh a'
There's no good solution for a split screen region being cleared: zombie windows prevent screen from exiting. I had to add additional synchronization between the windows and the caller script and when they all die, I call screen -X quit
explicitly.
The altscreen
command had nothing to do with this. The cursor didn't move to the bottom, because my default /etc/screenrc
was half-working: the host terminal altscreen feature was used, but the altscreen wasn't cleared before switching back. To make it work by default I copied /etc/screenrc
from CentOS 7
and for my case I disabled the feature completely with termcapinfo * ti=:te=
.
test.sh:
#!/bin/bash
# set -e
if [ "a" = "$1" ]; then
# decrement file name towards zero, then kill screen
set -e
a=-1
cd "$COUNTERDIR"
while true; do
for old in *; do
new=$((old + a))
done
[ 0 -eq "$a" ] || 2>/dev/null mv ./$old ./$new && break
done
if [ 0 -eq "$new" ]; then
screen -X quit
fi
exit
fi
NWINDOWS=2
COUNTERDIR=`mktemp -d`
touch "$COUNTERDIR/$NWINDOWS"
export COUNTERDIR
screen -c test.screen
rm -rf "$COUNTERDIR"
test.screen:
# do not use host terminal altscreen feature
termcapinfo * ti=:te=
# windows stay after command terminates
zombie kr
screen -t A sh -c 'for ((i=0; i<100; i++)); do echo important info $i; done && sleep 5; ./test.sh a'
split
focus
screen -t B sh -c 'for ((i=0; i<100; i++)); do echo another important info $i; done && sleep 2; ./test.sh a'
answered Oct 21 '17 at 7:16
basin
6881721
6881721
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398093%2fdo-not-clear-a-split-screen-region-when-one-command-completes%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password