Due to lots of power outages today I thought I should resurrect by usage of screen, which I have neglected recently.
It is difficult to explain what screen is, much easier to say what it does, or at least what I use it for. Screen allows you to resume an interactive terminal session, from any other machine. For example I ssh from ym desktop machine into our cluster then run R interactively, but if my local machine dies or I accidentally close the terminal window that session ends and I loose everything. However, if I use screen I can resume it. Better still I can go home VPN into work and resume the same session on my laptop. It is ideally for running long interactive jobs, without having to leave my desktop machine on overnight. I could also run screen on my desktop machine, log into the cluster, then ssh into my desktop from another machine and I can resume the session, getting straight into the cluster.
There are lots of features which are explained elsewhere, but I will detail how I use it and give my config files in case they are useful to anyone else.
It really couldn't be simpler to get started, just type screen. Nothing much will change, you are still at the terminal, and can do everything as normal, but now you can detach this session and resume at on another machine if you want to, or shut down your desktop and resume when you come back. To resume you just need to do screen -r.
Another great feature is having multiple screens, which is a bit like having a tabbed terminal window. So you can edit a file in one window, then quickly switch to the other one to run it. The Ctrl-z Ctrl-z command does this very quickly, see below. You can also split the screen, so you can edit at the top, run at the bottom, or maybe monitor something on the top while working on the bottom. Very nice.
I use emacs a lot, so the default screen key of Ctrl-a is a bit of a pain as that means move to the start of the line in emacs, something I do a lot. So I have re-mapped my screen key to Ctrl-z, though you can do anything. I have also made a few other changes to my .screenrc.
I also added the following lines to my .bashrc to stop screen Woofing at me. Yes, Woofing.
alias screen='TERM=screen screen'
Ctrl-z Ctrl-c : Create a new window
Ctrl-z " : Show a list of windows
.. : Switch to window x
Ctrl-z Ctrl-z : Toggle to previous window
Ctrl-z A : Name the current Window
Ctrl-z S : Split the window horizontally
Ctrl-z TAB : Move focus to other section of split screen
Ctrl-z Q : Remove all but current section
You can view all the default command by doing a Ctrl-z ? within screen, or using Google.
There is a lot more to screen than that, and maybe one day I will go into some of the most advanced features.