GNU Screen¶
Any system that doesn't have tmux will almost always have screen.
Building from Source¶
Build from source to enable 256color support.
curl -O https://ftp.gnu.org/gnu/screen/screen-4.9.1.tar.gz
tar -zxvf screen-4.9.1.tar.gz
sh autogen.sh &&
./configure --prefix=/usr \
--enable-colors256 \
--infodir=/usr/share/info \
--mandir=/usr/share/man \
--with-socket-dir=/run/screen \
--with-pty-group=5 \
--with-sys-screenrc=/etc/screenrc &&
sed -i -e "s%/usr/local/etc/screenrc%/etc/screenrc%" {etc,doc}/* &&
make
Basics¶
-
screen- Starts a new screen session.
-
screen -ls- This lists all screen sessions.
- Tmux has the same thing (as
tmux ls)
-
screen -r [processid]- This reattaches to the given process.
- If there's no
[processid], it will reattach to the last screen session.
-
screen -S [name]- This starts a new screen session with the given name.
-
screen -R [name]- This reattaches to a running screen session with the given name.
- If the session doesn't exist, it will be created.
-
screen -d [processid]- This detaches from the given process.
<C-a>dis the shortcut for this.
Default Keybindings:¶
Screen's default <leader> is <Ctrl-a>
Since this can be changed, I'll use <leader> to refer to it.
C-ais the prefix/leader.<leader> ?for a list of keybindings.<leader>w(or<leader>w) will show which window is active<leader>0: will take you to screen 0<leader>:: will take you to screen command line<leader>:help<CR>: shows help<leader>c: Create a new window.<leader>aa: Hop between screen windows<leader>d: detaches from current windowscreen -rto reattach
<leader>|: Split window vertically. (i.e.,<Shift>\)<leader>\: Kill all windows and terminate screen- Don't use this unless know you definitely want to.
Copy mode¶
<leader>[: Enter copy mode- Select text with
<enter(or space)> motion <enter>
- Select text with
<leader>]: Paste from screen buffer
To paste into vim/nvim:
:set pastei<leader>]
Regions¶
Regions don't take on their own terminal instance like in tmux.
You can use them to access other windows.
i.e., You can use a region to access window 2 while working in window 1.
Working with regions (called panes in tmux):¶
C-a SSplits the screen horizontally (capital S).C-a |Splits the screen vertically. (not\, that kills all the windows).C-a C-iswitches between regions (panes).C-a C-tabalso switches between regions (panes).C-a QKills all regions except the current one.
Screen Sharing with Multiuser Sessions¶
To share screen session with another user:
<leader>:multiuser on<leader>and then:to enter command mode:multiuser onto enable multi-user support
Get the screen session with <leader>d (detach) and screen -ls
Then other user will connect with screen -S [session_name]
This feature of Screen has more robust multi-user support than tmux.
Useful Commands for Multiuser Sessions¶
:displays: Lists all the currently connected user front-ends (displays).- In this interface you can detach displays.
din the:displaysinterface to detach that display.Din the:displaysinterface to force detach that display.
<space>while in this interface to refresh the list.
- In this interface you can detach displays.
The following is an example of what displays could look like:
xterm 80x42 jnweiger@/dev/ttyp4 0(m11) &rWx
facit 80x24 mlschroe@/dev/ttyhf nb 11(tcsh) rwx
xterm 80x42 jnhollma@/dev/ttyp5 0(m11) &R.x
(A) (B) (C) (D) (E) (F)(G) (H)(I)
(A): The terminal type known by screen for this display.(B): Displays geometry as width x height.(C): Username who is logged in at the display.(D): Device name of the display or the attached device(E): Display is in blocking or nonblocking mode. The available modes are "nb", "NB", "Z<", "Z>", and "BL".(F): Number of the window(G): Name/title of window(H): Whether the window is shared(I): Window permissions. Made up of three characters.