Advanced .screenrc Configuration: Productivity Hacks for GNU Screen Power Users


2 views

After years of terminal multiplexing, I've refined my .screenrc to maximize productivity. Here are the most valuable tweaks beyond basic configuration:

# Disable startup message for cleaner sessions
startup_message off

# Prevent visual bell flash in header
vbell off

# Maintain extensive scrollback history
defscrollback 10000

Create quick-access bindings for high-numbered windows (10-15):

bind -c selectHighs 0 select 10
bind -c selectHighs 1 select 11
bind -c selectHighs 2 select 12
bind -c selectHighs 3 select 13
bind -c selectHighs 4 select 14
bind -c selectHighs 5 select 15
bind - command -c selectHighs

This comprehensive status line shows hostname, window list with indicators, and datetime:

hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'

Key indicators:
%n* marks active window
%u shows bell notifications
%H displays hostname
• Color-coded segments improve readability

screen -t main     0   bash
screen -t monitor  1   htop
screen -t irc      2   irssi
screen -t python   3   ipython
screen -t logs     4   tail -f /var/log/syslog

1. Use shelltitle to track processes:

shelltitle "$ |bash"

2. For SSH sessions, add this to preserve window titles:

termcapinfo xterm*|rxvt*|kterm*|Eterm* 'hs:ts=\E]0;:fs=\007:ds=\E]0;\007'

Here's my battle-tested .screenrc configuration that solves common workflow challenges:

# Disable startup banner
startup_message off

# Enhanced scrollback buffer
defscrollback 5000

# Visual bell instead of audible
vbell on
vbell_msg "WARNING: Visual bell in window %n"

# Better terminal emulation for modern terminals
termcapinfo xterm* ti@:te@
termcapinfo xterm*|rxvt*|kterm*|Eterm* hs@:ts=\E]0;:fs=\007:ds=\E]0;\007

These bindings create a numeric window selection system:

# Quick window selection (0-9)
bind 0 select 0
bind 1 select 1
...
bind 9 select 9

# Extended window selection (10-19)
bind -c selectHighs 0 select 10
bind -c selectHighs 1 select 11
...
bind -c selectHighs 9 select 19
bind - command -c selectHighs

Pre-configured windows for common development tasks:

# Development environment presets
screen -t editor 0 vim
screen -t shell 1
screen -t debug 2 gdb
screen -t logs 3 tail -f /var/log/syslog
screen -t monitor 4 htop
screen -t db 5 mysql -u root -p

The most powerful feature - an informative status bar:

hardstatus alwayslastline
hardstatus string '%{= kG}[%H] %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}[%Y-%m-%d %c]'

# Alternative minimalist version:
# hardstatus string '%h%?%-Lw%?%{b}(%{w}%n*%f%t%?(%u)%?%{b})%{w}%?%+Lw%?%?%='

Add these productivity boosters:

# Mouse support in xterm
termcapinfo xterm*|rxvt* km=\E[?1;2;3;4;5;6;9;15;21;22;23;24;25;29;31;~:&

# UTF-8 support
defutf8 on

# Activity monitoring
activity "Activity in %n (%t)"

Ensure sessions survive disconnections:

# Auto-detach on hangup
autodetach on

# Logging
logfile /tmp/screenlog.%n
logfile flush 1