When I exit a screen, I want to be able to return to the terminal looking as I left it. But right now, all I can do is have it clear the screen and put the terminal at the top or the bottom through modifying my .screenrc
file.
I can get the interaction I want by doing tput smcup; screen -S hello; tput rmcup
,
but I don't think I can easily alias or safely make it into a function*.
How would I change my .screenrc
file to get this behavior?
Here is what I have tried to little effect from other Stack Exchange questions:
termcapinfo xterm|xterms|xs|rxvt ti@:te@
termcapinfo xterm*|rxvt* te=\E[?1049l:ti=\E[?1049h:
termcapinfo xterm*|rxvt* te=:ti=
from How to prevent GNU screen from clearing the screen when terminating?
I also read the answer to “Why doesn't the screen clear when running vi?” in the XTerm FAQ by Thomas E. Dickey, but couldn't translate it into something actionable.
Changing the term command didn't affect me and I didn't try the second part: Detaching from a GNU Screen suddenly clears the terminal (on Super User).
____________
* I did actually try my hand at it, but I'd like some confirmation that this wouldn't break anything:
jscreen () {
if [ $# -eq 2 ]; then
if [ $1 == "-r" ] || [ $1 == "-S" ]; then
tput smcup
screen $@
tput rmcup
return
fi
fi
screen $@
}
$@
without putting it in quotes:screen "$@"
. – G-Man Says 'Reinstate Monica' Nov 08 '22 at 04:41screen -S "help me"
to make a screen called\
help me``? And thanks for the code edit. – Jeff Nov 09 '22 at 16:43foo bar
by typingscreen -S "foo bar"
and later tries to reattach to it withscreen -r foo bar
, it won’t work. But the point is, if they run yourjscreen
function asjscreen -r "foo bar"
, and your function saysscreen $@
(without quotes), then your function will runscreen -r foo bar
, which won’t work. … (Cont’d) – G-Man Says 'Reinstate Monica' Nov 09 '22 at 19:36IFS
variable has been set to something weird, or when dealing with strings that contain any of the glob characters?
,*
or[
. See Security implications of forgetting to quote a variable in bash/POSIX shells, Why does my shell script choke on whitespace or other special characters?, and the other questions referenced in the [quoting] tag wiki. – G-Man Says 'Reinstate Monica' Nov 09 '22 at 19:36