GNU Screen can be configured through an *rc file, the .screenrc
. This file is usually placed in the home directory and contains configurations of key mappings, and windows’ titles and captions. Also, in the .screenrc
one can declare the type of the terminal (e.g. xterm256) and use the backtick command of Screen.
Here, I will present my .screenrc
file, which contains the following functionalities:
- Movement between split windows with Vim like configurations. That is, the movement between windows is with the Ctrl+a h/j/k/l keys.
- Resizing of windows with Vim-like mappings. That is, the resizing of windows can be done Ising Ctrl+a H/J/K/L. Note that the resizing is happening with the capital letters.
- Indication of the host in the lower left part of the status line
- Date and time of the machine where the Screen process is running, at the right part of the status line
- List of the open windows in the lower middle part of the status line
- Declaration of the terminal as capable of using 256 colors
- Activation/deactivation of the status line with Ctrl+a f/F
Also, I use some additional files depending if I’m working on my local machine (a macOS) or at the computational clusters that I have access (mostly Linux-based machines).
For the macOS case, I have two additional scripts that can be used in order to have GNU Screen display the artist and title from Music App. For the Linux case, I have one additional script which makes GNU Screen display the amount of currently running and submitted jobs at SLURM (SLURM is a workload/resources management system). You can find my screenrc file and all the extra scripts, at my GitHub repository for my screen files.
And here is a general form of my .screenrc
file! Enjoy!
# File: ~/.screenrc #
# Deactivate the startup message of screen startup_message off
# Vim like key bindings for moving around windows bind l focus right # C-a l goes right
bind h focus left # C-a h goes left
bind k focus up # C-a k goes up
bind j focus down # C-a j goes down
# Bind keys for resizing bind L resize -h +10 # C-a L increases horizontally by 10 bind H resize -h -10 # C-a H decreases horizontally by 10 bind K resize -v +10 # C-a K increases vertically by 10 bind J resize -v -10 # C-a K decreases vertically by 10
# Setup hardstatus
hardstatus off
hardstatus alwayslastline hardstatus string '%{= .g} %H |%=%{K}%{= w}%?%{K}%-Lw%?%{r}(%{W}%{w}%n%{w}*%f%t%?(%u)%?%{r})%{w}%?%{K}%+Lw%?%= %{g}|%{B} %m-%d %{W}%c %{g} '
# Fix for residual editor text altscreen on
# Fix for Name column in windowlist only show "bash" windowlist string "%4n %h%=%f"
# Indicate 256 color screen term screen-256color
# Bind Ctrl+A f or F for activating/deactivating hardstatus line bind f eval "hardstatus ignore" bind F eval "hardstatus alwayslastline"
# EOF