The GNU screen is unresponsive, seems blocked
In the commands below, replace Ctrl with whatever your escape key is for screen commands.
Try Ctrl+a q, which is the sequence to unblock scrolling.
Ctrl+a s is the sequence that blocks scrolling, which makes screen seem like it freezes.
How can I keep gnu screen from becoming unresponsive after losing my SSH connection?
With a great deal of experimentation, I was able to recover the screen session as follows:
- Lookup the PID of the server screen process: ps | grep screen
- Send the server a HUP signal: kill -1 <PID>
- Run a screen client: screen -r -d
GNU screen: output that causes the screen to scroll leaves garbage at the bottom of the window
I'm answering my own question here because, while @Keith Thompson's answer does resolve the symptom of the problem, it didn't keep the symptom from occurring. He did set me on the right path, which was to install the xterm package in cygwin-64. That appears to have resolved the issue.
What must I know to use GNU Screen properly?
I've been using Screen
for over 10 years and probably use less than half the features. So it's definitely not necessary to learn all its features right away (and I wouldn't recommend trying). My day-to-day commands are:
^A ^W - window list, where am I
^A ^C - create new window
^A space - next window
^A p - previous window
^A ^A - switch to previous screen (toggle)
^A [0-9] - go to window [0-9]
^A esc - copy mode, which I use for scrollback
I think that's it. I sometimes use the split screen features, but certainly not daily. The other tip is if screen seems to have locked up because you hit some random key combination by accident, do both ^Q
and ^A ^Q
to try to unlock it.
Kill detached screen session
"kill" will only kill one screen window. To "kill" the complete session, use quit
.
Example
$ screen -X -S [session # you want to kill] quit
For dead sessions use:
$ screen -wipe
How can I make GNU Screen start a new window at the CURRENT working directory?
See the GNU Screen chdir
command. All new windows created in Screen use this as their initial directory. Using this, you can do something like:
chdir /home/dan/newscreendir
screen
And your new window (along with any future created windows) will be in the set directory. If it's always going to be the current working directory you may be able to set something up in your screenrc
to do this one in one command.
See the GNU Screen man page. It's quite comprehensive.
Screen chdir command
Screen cannot access your shell variable nor execute backticked commands. The closest I can get to doing it in one click is with a small Bash script like this:
screen -X setenv currentdir `pwd`
screen -X eval 'chdir $currentdir' screen
Or more compactly:
screen -X eval "chdir $PWD"
screen -X
sends the command to the currently running Screen session. The first line creates a variable called currentdir
. The second line sends the currentdir
to the chdir
command and then creates a new Screen window.
What is GNU Screen?
What is GNU Screen? Great!
Erm, a slightly more useful answer: it allows you to run multiple console applications, or commands, in one terminal. Kind of like a tabbed terminal emulator. In fact, that's exactly what it is (just not done with the regular GUI toolkits)
Why is it so great? Simple, you can run a program in a screen session (Run screen
and it runs your default shell, run screen myapp
and it runs myapp in the session), hit ctrl+a (the screen control sequence) and then press d (ctrl+a,d) to detach.
The program keeps running in the background, but, unlike doing mycmd &
, you can run screen -r
to reattach the session, and everything is as you left it. You can send input to the command, if it's a curses UI, everything still works just like if it were a "real" terminal.
It's very popular with console IRC clients - you can run (say) screen irssi
and reattach the session from anywhere you can SSH from.
A few useful commands:
- ctrl+a, c to make a new virtual terminal (or "window") in the session
- ctrl+a, n and ctrl+a, p to cycle through multiple windows
- ctrl+a, 1 to select window 1, ctrl+a, 4 to select window 4 and so on
- ctrl+a, ctrl+a to flick between the last two active windows
- ctrl+a, shift+a (upper-case a) allows you to rename the current window
- ctrl+a, ` (for me, that's shift+2 - the quote mark) lists windows, you can use the arrows and select one. Also useful with the "tab bar" setting I'll list in a second
A few other useful things I've stumbled across:
- Use the
-U
flag when you launch screen so it supports Unicode (for example,screen -xU
) - The
-x
flag allows you to reattach the same session multiple times. (-r
disconnects existing connections) - You can do interesting stuff with the status bar. I have my setup to display
[ hostname ][ 0-$ bash (1*$ irssi) ][16/09 9:32]
(Running on hostname, it has two windows. This is set by the hardstatus lines in my .screenrc (at the end of the answer)
startup_message off
vbell off
hardstatus alwayslastline
hardstatus string '%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}]%{=y C}[%d/%m %c]%{W}'
GNU screen: output that causes the screen to scroll leaves garbage at the bottom of the window
I'm answering my own question here because, while @Keith Thompson's answer does resolve the symptom of the problem, it didn't keep the symptom from occurring. He did set me on the right path, which was to install the xterm package in cygwin-64. That appears to have resolved the issue.
GNU Screen: files to numbered buffers?
Maybe you want :readbuf
?
^A :readbuf /path/to/file
^A ]
I haven't used 'buffers' in GNU Screen (never knew they existed), but I'm guessing :readreg
is the buffer-y version of :readbuf
:
^A :readreg x /path/to/file
^A :paste x
Related Topics
How to Write Multiple Line String Using Bash with Variables
Symbolic Link to a Hook in Git
How to Convert Date to Unix Timestamp in Shell Script on MACos
Best Distributed Filesystem for Commodity Linux Storage Farm
What Is the Reason and How to Avoid the [Fin, Ack] , [Rst] and [Rst, Ack]
How to Find from Where a Job Is Submitted in Slurm
Stracing to Attach to a Multi-Threaded Process
How to Configure Curl to Only Show Percentage
How to Input Password to Git Pull Command
Force Unmount of Nfs-Mounted Directory
How to Edit a Binary File on Unix Systems
How to Install Crontab on Centos
How to Set Nginx Max Open Files
How to Monitor Data on a Serial Port in Linux
How Does Epoll's Epollexclusive Mode Interact with Level-Triggering
Linux: Screen Desktop Video Capture Over Network, and Vnc Framerate