GNU Screen is an often overlooked application which allows you to run programs in a console section, detach from them and then later resume them. They even keep running when you logout.
To make it more obvious which window you’re currently working in you can setup a small status bar across the bottom of the window which show you how many windows you have open, and which one you are working with.
To do this create a file .screenrc in your home area and place the following inside it:
# An alternative hardstatus to display a bar at the bottom listing the # windownames and highlighting the current windowname in blue. (This is only # enabled if there is no hardstatus setting for your terminal) hardstatus on hardstatus alwayslastline hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "
(You can override all the default settings in your local file, or update the global file in /etc/screenrc to affect all users).
To sum up we’ve seen that screen is a very powerful tool for executing commands that run for a long time, and running multiple programs all at the same time in a single session.
We’ve not covered all the options, just enough to get started with. Running man screen will give you lots more options.
- screen
- Run a new screen session
- screen -R
- Reattach to a previously detatched session
- Ctrl-a c
- Create a new window.
- Ctrl-a k
- Kill the current window – after confirmation
- Ctrl-a Ctrl-a
- Switch to the other window
- Ctrl-a S
- Split the current window in two.
- Ctrl-a TAB
- Move between split sections of the screen.
- Ctrl-a A
- Give the the current window a name.
- Ctrl-a ”
- List all windows – move around to change the window with the arrow keys