Jotting a little something down for the benefit of myself when I invariably forget how I did this, and for others if they are looking for the very best in Screen on X11. (There are plenty of general Screen tutorials on the Internet, a good one is at the Gentoo Linux Wiki).
Using this method, you will set up your favorite terminal emulator (Konsole, in my case) to attach to a multi-display Screen session instead of starting the default shell every time you run the program. Doing this, all of your Konsoles will work on a shared pool of Screen windows that you could also attach to over SSH, on the Linux console, or however else.
To start, the following configuration setting defines an alias which can be used to fire up your ultimate “create once, use everywhere” Screen session.
~/.bashrc
...
alias main-screen='screen -A -O -U -x -R -S main-screen'
...
When main-screen is run inside bash, Screen is started with the following options:
-A Adopt the size of the terminal (only
when the session was previously detached).
-O Better output mode for certain terminals.
-U Run Screen in UTF-8 mode.
-x Attach to the session, even if it is
attached elsewhere (multi display mode).
-R Create a session if it doesn't exist.
-S main-screen All of these options apply to a session named
main-screen
This allows multiple terminals, terminal emulators, SSH sessions, etc. to attach to the one Screen session. Each terminal has their own focus history, so for example, your xterm may be viewing Screen window 4, while an SSH session is focused on window 1. Or, they could be on the same window, in which case they see the same information, including what the other sessions are typing.
This creates a very convenient central Screen session that you can use any way you can imagine, organizing all of your windows in one session without disturbing previous Screen attaches you started. Inside X11, the last step is to automate running the screen alias.
I prefer KDE's Konsole, so this example is for it. If you use some other terminal emulator, it's up to you to figure out what to do.
- Start Konsole.
- Bring up the Settings menu and Configure Konsole...
- Click the Session tab.
- Enter a new name for your session, such as “Main Screen”.
- In the Execute field, enter:
bash -i -c main-screen
- Set other options as you desire.
- Save the session.
- Edit
.kde/share/config/konsolerc and change DefaultSession to DefaultSession=Main Screen.desktop (why you can't do this in the GUI I do not know).
- Save konsolerc and exit Konsole.
- Restart Konsole and you should be presented with your Screen session.
Now, whenever you start Konsole, you'll be attached to your main-screen Screen session, and can live free, blissful in the knowledge that all of your consoles are a few mouse (or key) presses away.