GNU Screen - Screens In Screens
GNU Screen has the ability to alter the escape key so that you can have screens in screens.
The default is:
escape ^Aa
So to open a new window its Ctrl+a c.
My escape line looks like:
escape ^\\
Since I have vim mapping my macros to \ I use Ctrl+\ in screen.
GNU Screen - Binding Macros
GNU Screen offers two ways of mapping a command to a key.
The first option is to use the bindkey directive. Everytime you press the key the command will run. This is useful for F1-F12 keys.
The second option is to use the bind directive. To run a command you have to press the escape key and then the letter. By default the escape is Ctrl+A
One cool feature of GNU Screen is that you can use the echo command to set the window title.
The command is echo -en "\ek Window Title\e\" -- This will replace your window title with "Window Title"
So I have in my ~/.screenrc file:
bind e stuff 'echo -en "\ekU@H\e\"|sed -e "s/H/`hostname`/" -e "s/U/`whoami`/"'
This command will replace the screen window title with username@hostname of the computer I am logged into when I press escape + e
GNU Screen - Hard Status Line
This is probably one of the most useful programs with a well written .screenrc file.
So here is the hard status line that I use
hardstatus alwayslastline '%{= kG}%{g}[ %{y}%H %{g}][%15= %>%=%-Lw%40>%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{g}%+Lw%=%-22< ][%{c} %Y-%m-%d %c %{g}]'
Now for how it works...
%{= kG}{g}[ -- Start with a green [
%{y}%H -- the hostname in dark yellow (looks like brown on my computer)
%{g}] -- Green ]
%15 -- Force a gap on the left for the hostname
%> -- Set a marker here for truncation
%= -- Pad with width (this will by default force everything to the right side of the screen)
%-Lw -- print all the other screen windows before the active one
%40> -- limit the other windows to 40% width
%{r}( -- red (
%{W}%n*%f %t -- white bold text of the window number %n, a * which I use to mark the active screen, active flags %f, and the title
%?(%u)%? -- show other users in () if they exist
%{r}) -- print out a red )
%{g}%+Lw -- print all the other screen windwos after the active one in green
%= -- Pad with width on the right side (this will have the effect of forcing the left side to truncate and putting windows naturally in the middle
%-22< -- Leave room for the date and time
][%{c} %Y-%m-%d %c %{g}] -- add the closing green ] and cyan date/time surrounded in []