In a bash
script I want to show the user a file with less
, but I don't want less
to take up the whole terminal: I need to keep some informations visible in the terminal while the user browses the file with less
.
I googled for terminal split linux
and all the results refer to the screen
command.
After several hours of trials end errors I believe I've come up with a mostly working solution. I've created a screen.rc
file containing:
split
screen 1 less /etc/passwd
focus down
resize 10
screen 2
exec !.. echo Informations area
focus up
Now, in my bash
script, I can run
screen -c screen.rc
and it creates a split terminal with less /etc/passwd
output in the top region and Information area
in the bottom one and the top region is receiving user input, which is exactly the intended behavior. Almost perfect, except when the user hits q
to terminate less
, screen
does not terminate, because there's still a running shell in the bottom region. The user now needs to focus the bottom region (CTRL+a TAB) and hit Ctrl+d to terminate the running bash
.
So the sequence to exit my custom less
file viewer has now become q
CTRL+a
TAB
CTRL+d
: quite a lot of keystrokes only to exit a text file viewer...
How can I make screen
terminate immediately when the top region less
command quits?
"${STY}"
? Thanks. – Lucio Crusca May 08 '18 at 23:38