Starting multiple Screen windows from shell script uses wrong configuration
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
When running Screen, I can use Ctrl+ac to create a new window and run vim in each window. Also from Screen, I can run the command screen vim
multiple times to open new windows with vim already running. These work as expected. However...
If I put the command multiple times in a script, such as:
#!/bin/bash
screen vim
screen vim
screen vim
...and run that script from within Screen, the first command will run as expected, but the second and following ones will not.
Things I have noticed are:
- Window 2 and beyond does not have
stty -ixon
applied, which I have set in .bashrc - If I don't have
colorscheme
set explicitly in .vimrc, it will use one scheme in window 1 and another in all following windows - Sometimes a command will be skipped, i.e., sometimes only two new windows will be opened where the script was set to open three
- If I do a
:windowlist
, window 2 and following will not have the login flag set (runningscreen vim
directly will set this flag), e.g.,
Num Name Flags
0 bash $
1 vim $ <-- running the script from window 0 opened 1..3 (no flag on 2 or 3)
2 vim
3 vim
4 vim $ <-- manually running `screen vim` from window 0 always sets the flag
- Using Ctrl+aL on a window that's not logged in will return the message
This window is not logged in
and the flag will not be set. Pressing the keys again will then toggle between logged in and out (thoughstty -ixon
etc' will still not be applied) - Running
htop
will show all instances of vim (including ones that are not logged in) are running under my user.
Why does manually opening multiple windows apply my settings correctly, but using a script doesn't?
I am new to Linux and not sure if I'm doing something silly here.
bash ubuntu vim gnu-screen stty
add a comment |Â
up vote
1
down vote
favorite
When running Screen, I can use Ctrl+ac to create a new window and run vim in each window. Also from Screen, I can run the command screen vim
multiple times to open new windows with vim already running. These work as expected. However...
If I put the command multiple times in a script, such as:
#!/bin/bash
screen vim
screen vim
screen vim
...and run that script from within Screen, the first command will run as expected, but the second and following ones will not.
Things I have noticed are:
- Window 2 and beyond does not have
stty -ixon
applied, which I have set in .bashrc - If I don't have
colorscheme
set explicitly in .vimrc, it will use one scheme in window 1 and another in all following windows - Sometimes a command will be skipped, i.e., sometimes only two new windows will be opened where the script was set to open three
- If I do a
:windowlist
, window 2 and following will not have the login flag set (runningscreen vim
directly will set this flag), e.g.,
Num Name Flags
0 bash $
1 vim $ <-- running the script from window 0 opened 1..3 (no flag on 2 or 3)
2 vim
3 vim
4 vim $ <-- manually running `screen vim` from window 0 always sets the flag
- Using Ctrl+aL on a window that's not logged in will return the message
This window is not logged in
and the flag will not be set. Pressing the keys again will then toggle between logged in and out (thoughstty -ixon
etc' will still not be applied) - Running
htop
will show all instances of vim (including ones that are not logged in) are running under my user.
Why does manually opening multiple windows apply my settings correctly, but using a script doesn't?
I am new to Linux and not sure if I'm doing something silly here.
bash ubuntu vim gnu-screen stty
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
When running Screen, I can use Ctrl+ac to create a new window and run vim in each window. Also from Screen, I can run the command screen vim
multiple times to open new windows with vim already running. These work as expected. However...
If I put the command multiple times in a script, such as:
#!/bin/bash
screen vim
screen vim
screen vim
...and run that script from within Screen, the first command will run as expected, but the second and following ones will not.
Things I have noticed are:
- Window 2 and beyond does not have
stty -ixon
applied, which I have set in .bashrc - If I don't have
colorscheme
set explicitly in .vimrc, it will use one scheme in window 1 and another in all following windows - Sometimes a command will be skipped, i.e., sometimes only two new windows will be opened where the script was set to open three
- If I do a
:windowlist
, window 2 and following will not have the login flag set (runningscreen vim
directly will set this flag), e.g.,
Num Name Flags
0 bash $
1 vim $ <-- running the script from window 0 opened 1..3 (no flag on 2 or 3)
2 vim
3 vim
4 vim $ <-- manually running `screen vim` from window 0 always sets the flag
- Using Ctrl+aL on a window that's not logged in will return the message
This window is not logged in
and the flag will not be set. Pressing the keys again will then toggle between logged in and out (thoughstty -ixon
etc' will still not be applied) - Running
htop
will show all instances of vim (including ones that are not logged in) are running under my user.
Why does manually opening multiple windows apply my settings correctly, but using a script doesn't?
I am new to Linux and not sure if I'm doing something silly here.
bash ubuntu vim gnu-screen stty
When running Screen, I can use Ctrl+ac to create a new window and run vim in each window. Also from Screen, I can run the command screen vim
multiple times to open new windows with vim already running. These work as expected. However...
If I put the command multiple times in a script, such as:
#!/bin/bash
screen vim
screen vim
screen vim
...and run that script from within Screen, the first command will run as expected, but the second and following ones will not.
Things I have noticed are:
- Window 2 and beyond does not have
stty -ixon
applied, which I have set in .bashrc - If I don't have
colorscheme
set explicitly in .vimrc, it will use one scheme in window 1 and another in all following windows - Sometimes a command will be skipped, i.e., sometimes only two new windows will be opened where the script was set to open three
- If I do a
:windowlist
, window 2 and following will not have the login flag set (runningscreen vim
directly will set this flag), e.g.,
Num Name Flags
0 bash $
1 vim $ <-- running the script from window 0 opened 1..3 (no flag on 2 or 3)
2 vim
3 vim
4 vim $ <-- manually running `screen vim` from window 0 always sets the flag
- Using Ctrl+aL on a window that's not logged in will return the message
This window is not logged in
and the flag will not be set. Pressing the keys again will then toggle between logged in and out (thoughstty -ixon
etc' will still not be applied) - Running
htop
will show all instances of vim (including ones that are not logged in) are running under my user.
Why does manually opening multiple windows apply my settings correctly, but using a script doesn't?
I am new to Linux and not sure if I'm doing something silly here.
bash ubuntu vim gnu-screen stty
asked Jan 14 at 7:11
Eliott
63
63
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
I believe I found that the problem is caused by the script running all commands (except the first) in the background. I can force the first command to have the same problem by forking it with &
.
After not being able to find a way to have the script run each command in the foreground, one-after-the-other, I have found an alternative solution...
I can put all the commands in a custom screenrc file (e.g., my_screenrc) as such:
# Import default screenrc
source $HOME/.screenrc
# Run screen-specific commands (not bash ones)
screen # Run bash in window 0
screen vim # Run vim in windows 1 through 3 (with correct settings)
screen vim
screen vim
I can then run this from bash with:
screen -c my_screenrc
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
I believe I found that the problem is caused by the script running all commands (except the first) in the background. I can force the first command to have the same problem by forking it with &
.
After not being able to find a way to have the script run each command in the foreground, one-after-the-other, I have found an alternative solution...
I can put all the commands in a custom screenrc file (e.g., my_screenrc) as such:
# Import default screenrc
source $HOME/.screenrc
# Run screen-specific commands (not bash ones)
screen # Run bash in window 0
screen vim # Run vim in windows 1 through 3 (with correct settings)
screen vim
screen vim
I can then run this from bash with:
screen -c my_screenrc
add a comment |Â
up vote
0
down vote
accepted
I believe I found that the problem is caused by the script running all commands (except the first) in the background. I can force the first command to have the same problem by forking it with &
.
After not being able to find a way to have the script run each command in the foreground, one-after-the-other, I have found an alternative solution...
I can put all the commands in a custom screenrc file (e.g., my_screenrc) as such:
# Import default screenrc
source $HOME/.screenrc
# Run screen-specific commands (not bash ones)
screen # Run bash in window 0
screen vim # Run vim in windows 1 through 3 (with correct settings)
screen vim
screen vim
I can then run this from bash with:
screen -c my_screenrc
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I believe I found that the problem is caused by the script running all commands (except the first) in the background. I can force the first command to have the same problem by forking it with &
.
After not being able to find a way to have the script run each command in the foreground, one-after-the-other, I have found an alternative solution...
I can put all the commands in a custom screenrc file (e.g., my_screenrc) as such:
# Import default screenrc
source $HOME/.screenrc
# Run screen-specific commands (not bash ones)
screen # Run bash in window 0
screen vim # Run vim in windows 1 through 3 (with correct settings)
screen vim
screen vim
I can then run this from bash with:
screen -c my_screenrc
I believe I found that the problem is caused by the script running all commands (except the first) in the background. I can force the first command to have the same problem by forking it with &
.
After not being able to find a way to have the script run each command in the foreground, one-after-the-other, I have found an alternative solution...
I can put all the commands in a custom screenrc file (e.g., my_screenrc) as such:
# Import default screenrc
source $HOME/.screenrc
# Run screen-specific commands (not bash ones)
screen # Run bash in window 0
screen vim # Run vim in windows 1 through 3 (with correct settings)
screen vim
screen vim
I can then run this from bash with:
screen -c my_screenrc
answered Jan 26 at 5:24
Eliott
63
63
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%2f416979%2fstarting-multiple-screen-windows-from-shell-script-uses-wrong-configuration%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