GNU Screen is one of the most useful utilities on a *nix system. On OpenBSD, it’s an installable package (“sudo pkg_add -i screen“) and it’s almost always the first package I install.
Scott (whose blog is not as fast as mine) and I played around with our ${HOME}/.screenrc and Scott helped me come up with this:
shell -$SHELL
startup_message off
defscrollback 1000
hardstatus alwayslastline '%{= wk}%?%-Lw%?%{r}(%{k}%n*%f%t%?(%u)%?%{r})%{k}%?%+Lw%?%?%= %m/%d %C%A'
activity ''
termcapinfo xterm* 'hs:ts=\\E]2;:fs=\\007:ds=\\E]2;screen\\007'
File explanation:
- “shell -${SHELL}” tells screen not only to use my default shell, but the “-” tells it to use it as a login shell (parsing my start-up scripts).
- “startup_message off” tells screen that I don’t want to read the license each time I run screen. I agree. I agree.
- “defscrollback 1000″ tells screen to increase the scrollback buffer from the default (100).
- The “hardstatus alwayslastline” tells screen that I want a status line at the bottom of the screen and the other text specifies that I want screen to display the screen window names/numbers and the date/time.
- “activity ”” tells screen not to display text when a monitored window has activity (only change its indicator on the status line)
- “termcapinfo xterm*” tells screen to update the titlebar for OS X’s Terminal.
Here are some of my screen “tips and tricks”, including some basics:
- To create a new screen window, press ^a^c (that’s Control+a, Control+c)
- To swap between the current window and the previous one: ^a^a
- To switch to window 1: ^a1
- To detach: ^a^d
- To reattach to the only screen session running: screen -R
- To list screen sessions: screen -ls
- To attach to a specific session: screen -r n (where n is the PID of a screen session)
- To detach a session attached at another login session and attach to it locally: screen -dr n
- Split the screen into two regions: ^aS (note the capital S)
- Swap between regions on the screen: ^a[tab] (that’s Control+a, TAB)
- Kill the current region: ^aX (capital X, note that while the region is removed from the screen, the “window” is still running)
- Rename a window: ^aA (capital A)
- List windows: ^a”
- Literal Control+A: ^aa
- To start a new screen window with a title from within screen: screen -t title command_line
- Monitor a window for changes and note its changes with a @ in the status bar (or “sound” the bell): ^aM
There’s MUCH, MUCH more to screen, but this is how I use it.
By Andrei GUDIU
in Split the screen into two regions: ^a^S (note the capital S)
replace ^a^S with ^aS
By Andrei GUDIU
Same with Kill the current region: ^a^X (capital X, note that while the region is removed from the screen, the “window” is still running)
replace ^a^X with ^aX
By merdely
Andrei, You’re absolutely right. Thanks for the heads up. Fixed.
By Alex
Thanks for the tip about splitting window into regions, I didn’t know about that one.
By sepp0
You use Awesome with screen?
By merdely
> You use Awesome with screen?
More accurately, I use screen (now tmux) with Awesome. Yes. I have xterms running inside Awesome with tmux (used to be screen) running inside the xterms.