⚠ Now, before anything, I personally wouldn’t recommend switching to GNU screen
if you already have a tmux
configuration. I believe tmux
excels in terms of extensibility, documentation, and community support, with numerous videos and guides available. This blog post is best suited for those who might not have a terminal multiplexer setup yet and are looking for something simple, built-in, and somewhat “suckless” 🧩.
GNU screen
provides all the necessities of a terminal multiplexer with a few essential features and configurability options sprinkled on top ✨. If you don’t foresee the need to heavily extend the tool, want to keep your setup straightforward, and aren’t interested in creating elaborate configurations for show, GNU screen
might be perfect for those long SSH sessions and productive late nights with text editors like Neovim and other CLI tools.
In this post, I’ll share my simple GNU Screen setup, which I find more than sufficient for my needs. I hope this post serves as a good starting point for anyone looking to configure a terminal multiplexer 👍.
The Set-up
I have two concurrent GNU screen
setups on my machines. One for when I am in a session where the X11
display server is running (essentially, when using a graphical environment):
And another for when I am in a TTY session (a text-based environment without a graphical interface):
The “Top Bar”
The hardstatus
line consists of a few basic elements:
- A (Top-left) — a simple hard-coded
[ GNU screen ]
indicator to signify that you are in an attached session. - B (Middle-left) — a horizontal “window buttons list” similar to a taskbar in a panel.
- The “Active Window” is represented within "
(==
" and "==)
“. - The X11
screen
config has more verbose “window” titles.
- The “Active Window” is represented within "
- C (Top-right) — a “textclock” displaying the date, day, and time (only present in the
tty
config).
This setup is meant to be “functionally simple” and not reliant on any Nerd Fonts or other non-ASCII characters, so you can get up and running with a multiplexer even on a barebones Linux install.
Keybindings
My preferred “prefix” key is Ctrl
+space
(instead of the default, Ctrl
+a
). This prefix key seems to conflict less with known default terminal programs’ keybindings unless it was explicitly set in said tools (e.g., in a VI/Vim/Neovim config). Here are some of my configuration’s keybindings based on the common commands presented in the ArchWiki.
Keybind | Action |
---|---|
Ctrl+space " | toggle window list |
Ctrl+space 1 | open window 1 |
Ctrl+space 0 | open window 10 |
Ctrl+space ? | display commands and their defaults |
Ctrl+space A | rename the current window |
Ctrl+space Esc | enter copy mode (use enter to select a range of text) |
Ctrl+space Q | close all regions but the current one |
Ctrl+space S | split the current region horizontally into two regions |
Ctrl+space ] | paste text |
Ctrl+space a | send ctrl+a to the current window |
Ctrl+space c | create a new window (with shell) |
Ctrl+space d | detach from the current screen session and leave it running. use screen -r to resume |
Ctrl+space k | “kill” the current window |
Ctrl+space tab | switch the input focus to the next region |
Ctrl+space | | split the current region vertically into two regions |
Ctrl+space : | enter the command prompt of screen |
Ctrl+space :quit | close all windows and close the screen session |
Ctrl+space :source | reload the screenrc configuration file (can alternatively use /etc/screenrc) |
Replicate My GNU Screen Config 🚀
Due to my VI/Neovim configuration requiring True Color (24-bit) support, I use GNU Screen 5.0.0 (the -git master branch), which finally has the truecolor
setting. For those who prefer not to compile software and would rather stick with the versions available in the repositories, I also have a similar configuration that works with screen
versions <= 4.9.1
(which only support 256 colors). I will share both configurations in this blog post.
GNU Screen 5.0.0 (-git master branch)
Installation Instructions for GNU Screen -git
The following are installation instructions for Linux distributions that have a -git
GNU screen
package.
Arch Linux (AUR)
$ paru -S screen-git
or
$ yay -S screen-git
or
# Download screen-git PKGBUILD
$ wget 'https://aur.archlinux.org/cgit/aur.git/snapshot/screen-git.tar.gz'
# Extract Tarball
$ tar -xvf screen-git.tar.gz
# Change Directory to screen-git/
$ cd screen-git/
# Build Package
$ makepkg -si
Building From Source
The following are build instructions for the -git
version of GNU screen
.
Install Dependencies for Your Distro
Ubuntu/Debian
$ sudo apt update && sudo apt install -y git autoconf automake libtool make gcc libncurses5-dev libpam0g-dev libssl-dev
Fedora
$ sudo dnf install -y git autoconf automake libtool make gcc ncurses-devel pam-devel openssl-devel
Gentoo
$ sudo emerge dev-vcs/git autoconf automake libtool gcc sys-libs/ncurses sys-libs/pam dev-libs/openssl
Alpine Linux
$ sudo apk add git autoconf automake libtool make gcc ncurses-dev pam-dev openssl-dev
OpenSUSE
$ sudo zypper install -y git autoconf automake libtool make gcc ncurses-devel pam-devel libopenssl-devel
Clone, Build, and Run GNU screen
# Clone Source
$ git clone https://git.savannah.gnu.org/git/screen.git
# Switch to screen/src directory
$ cd screen/src
# Build GNU Screen
$ NOCONFIGURE=1 ./autogen.sh
$ sh ./configure \
--prefix=/usr/local \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--enable-pam \
--enable-telnet \
--with-pty-group=$_ptygroup
$ make
# Optional
$ sudo make install # or place binary in a PATH= directory
# Run and Test GNU screen
$ ./screen
Configuration (GNU Screen 5.0.0 -git
)
~/.screenrc
# this config requires Screen v5 (-git master branch release)
truecolor on
hardstatus off # puts notifications at the bottom
hardstatus alwaysfirstline '%{#999999}[ GNU screen ]%{#ffffff} %< %{7}%?%-Lw%?%{1;0}%{#009dff}(== %{#ffffff}%n %h%?(%u)%?%{1;0}%{#009dff} ==)%{7}%?%+Lw%?%?'
altscreen on
bind 0 select 10
bind c screen 1
defscrollback 5000
escape ^@a
maptimeout 0
screen 1
startup_message off
or
~/.screenrc
(with clock, as found in my TTY config):
# this config requires Screen v5 (-git master branch release)
truecolor on
backtick 0 5 5 "/usr/bin/date" '+%m/%d (%a)'
backtick 1 5 5 "/usr/bin/date" '+%H%M'
hardstatus off # puts notifications at the bottom
hardstatus alwaysfirstline '%{#999999}[ GNU screen ]%{#ffffff} %< %{7}%?%-Lw%?%{1;0}%{#009dff}(== %{#ffffff}%n%f%t%?(%u)%?%{1;0}%{#009dff} ==)%{7}%?%+Lw%?%? %= %{#999999}[ %{#999999}%0` %1` ]'
altscreen on
bind 0 select 10
bind c screen 1
defscrollback 5000
escape ^@a
maptimeout 0
screen 1
startup_message off
GNU Screen 4.0.0+ (Stable Release Across Distros)
Installation Instructions for GNU Screen 4.0.0+
GNU Screen version 4.0.0+ is widely available across various Linux distributions through their respective package managers. Below are the installation commands for some common distributions.
Debian/Ubuntu
$ sudo apt update
$ sudo apt install screen
Fedora
$ sudo dnf install screen
Arch Linux
$ sudo pacman -S screen
Gentoo
$ sudo emerge --ask app-misc/screen
Alpine Linux
$ sudo apk add screen
openSUSE
$ sudo zypper install screen
After installation, you can run GNU Screen by simply typing screen
in your terminal.
Configuration (GNU Screen 4.0.0+)
.screenrc
attrcolor b ".I"
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
defbce on
backtick 0 5 5 "/usr/bin/date" '+%m/%d (%a)'
backtick 1 5 5 "/usr/bin/date" '+%H%M'
hardstatus alwaysfirstline
hardstatus string '%{= kW}[%{W} GNU screen %{W}]%{W} %< %{kW}%?%-Lw%?%{= kB}(== %{W}%n*%f %t%?(%u)%? %{kB}==)%{= kW}%?%+Lw%?%? %= %{kW}[%{W}%0` %{W}%1`%{kW}]'
altscreen on
bind 0 select 10
bind c screen 1
defscrollback 5000
escape ^@a
maptimeout 0
screen 1
startup_message off
Dynamic screen
Configuration Based on Session
On my machines, these configs are dynamically loaded based on session. I also follow the XDG Base Directory Specification by declaring the SCREENRC=
environment variable, which moves the configuration from ~/.screenrc
to whatever path is specified in the variable.
If you would also like to load individual configs based on whether you’re in an X11 or a TTY session, refer to this snippet of my .config/shell/profile
:
#!/bin/sh
…
# X11-dependent env variables
if [ -n "$DISPLAY" ] && xhost >/dev/null; then
setxkbmap -option compose:ralt
xset r rate 300 50
export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc
export XPROFILE_X11_SPECIFICS=loaded
else # if TTY
export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc-if-tty
export XPROFILE_X11_SPECIFICS=unloaded
echo "X11 is not running... X11-related settings have been skipped"
fi
This file is sourced by my fish
shell config (via a method similar to what is mentioned in the ArchWiki). The file is also symlinked to .zprofile
, .profile
, and .xprofile
/.xsessionrc
in case I want to go back to using zsh
or bash
as my default shell again.
Changing the “Prefix” Key
If you would like to have a different “prefix” key, you can run showkey -a
to examine the codes sent by the keyboard and then grab the ASCII output, append an “a”, and modify the config like so:
To apply, replace the escape ^@a
line in the config with:
escape ^\a
For more information on this, you can refer to the ArchWiki’s “Change The Escape Key” GNU Screen Article.
Downloadables
Wrapping Up 🎁
That’s it for my simple GNU Screen setup! While GNU Screen might not be as feature-rich as tmux
, I believe it offers a straightforward and functional alternative for those who prefer simplicity and minimalism with their tools. The configurations shared here should provide a solid foundation to get you started. Feel free to experiment with the configs and make them your own.
Happy hacking, and may your terminal sessions be ever efficient and productive! 🚀