using screen to split the terminal
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
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?
gnu-screen
add a comment |Â
up vote
0
down vote
favorite
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?
gnu-screen
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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?
gnu-screen
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?
gnu-screen
asked May 8 at 22:59
Lucio Crusca
1034
1034
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Sending the quit
command will tell screen to quit, so replace the less
command with:
screen 1 sh -c 'less /etc/passwd ; screen -S "$STY" -X quit'
or something to that effect.
can you please explain that"$STY"
? Thanks.
â Lucio Crusca
May 8 at 23:38
STY â Alternate socket name.
â Ignacio Vazquez-Abrams
May 8 at 23:45
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Sending the quit
command will tell screen to quit, so replace the less
command with:
screen 1 sh -c 'less /etc/passwd ; screen -S "$STY" -X quit'
or something to that effect.
can you please explain that"$STY"
? Thanks.
â Lucio Crusca
May 8 at 23:38
STY â Alternate socket name.
â Ignacio Vazquez-Abrams
May 8 at 23:45
add a comment |Â
up vote
1
down vote
accepted
Sending the quit
command will tell screen to quit, so replace the less
command with:
screen 1 sh -c 'less /etc/passwd ; screen -S "$STY" -X quit'
or something to that effect.
can you please explain that"$STY"
? Thanks.
â Lucio Crusca
May 8 at 23:38
STY â Alternate socket name.
â Ignacio Vazquez-Abrams
May 8 at 23:45
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Sending the quit
command will tell screen to quit, so replace the less
command with:
screen 1 sh -c 'less /etc/passwd ; screen -S "$STY" -X quit'
or something to that effect.
Sending the quit
command will tell screen to quit, so replace the less
command with:
screen 1 sh -c 'less /etc/passwd ; screen -S "$STY" -X quit'
or something to that effect.
answered May 8 at 23:14
Ignacio Vazquez-Abrams
32k66780
32k66780
can you please explain that"$STY"
? Thanks.
â Lucio Crusca
May 8 at 23:38
STY â Alternate socket name.
â Ignacio Vazquez-Abrams
May 8 at 23:45
add a comment |Â
can you please explain that"$STY"
? Thanks.
â Lucio Crusca
May 8 at 23:38
STY â Alternate socket name.
â Ignacio Vazquez-Abrams
May 8 at 23:45
can you please explain that
"$STY"
? Thanks.â Lucio Crusca
May 8 at 23:38
can you please explain that
"$STY"
? Thanks.â Lucio Crusca
May 8 at 23:38
STY â Alternate socket name.
â Ignacio Vazquez-Abrams
May 8 at 23:45
STY â Alternate socket name.
â Ignacio Vazquez-Abrams
May 8 at 23:45
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%2f442646%2fusing-screen-to-split-the-terminal%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