Reputation: 2200
I'm writing a shell script which utilises screen to display several things at once (split screens) One of the windows will be the "gui" code which will ask the user questions while other windows display various progress items.
Part way through the script I have a need to vim a file. But this part of the code is within a subshell with redirected inputs. vim does not work well here*
So I figured I could open up a new screen window and load vim in there screen -X screen vim file
The problem is I need the gui code to wait until vim has quit before continuing.
So how can I wait for a specific screen window to end, from within screen?
screen -ls
will not work here because it is only one of several windows within the whole session which I need to monitor.
I've also looked at screen -QX windows
but this would appear to interrupt the vim session
* Relating to vim and the subshell: I've tried using exec 3<&1; cat file1 | ( read whatever; vim file2 <&3 )
but this has some major issues (e.g. can't see the first few lines of the file!)
Upvotes: 1
Views: 498
Reputation: 2200
Based on @William's comment this code:
screen -X screen vim --servername MYSERVER`
sleep 1
vim --servername MYSERVER --remote-wait file.txt
opens up vim in a separate window (and focusses it) and then opens the file into that session and waits until the user quits vim
The sleep would appear to be required to give them vim session time to start up, otherwise the 2nd command can't find the vim server and instead tries to edit locally (which won't work inside the redirected subshell)
Upvotes: 1