When working with GNU Screen, modifying the .screenrc
configuration file typically requires restarting the session to apply changes. However, in production environments or during long-running processes, restarting may not be practical.
GNU Screen provides a built-in way to reload configuration without session interruption:
Ctrl+a :source ~/.screenrc
For frequent configuration updates, consider creating a custom key binding in your .screenrc
:
# Add to .screenrc
bind R source ~/.screenrc
Now simply press Ctrl+a R
to reload your configuration.
For development environments with multiple configuration files:
# Reload specific config file
Ctrl+a :source /path/to/custom.screenrc
# Debugging reloads
Ctrl+a :debug on
Ctrl+a :source ~/.screenrc
If changes don't appear after reloading:
- Verify file paths are absolute in your
.screenrc
- Check for syntax errors using
screen -T xterm -c ~/.screenrc
- Some settings (like escape character) require session restart
For team environments, combine with inotifywait for automatic reloading:
#!/bin/bash
while inotifywait -e modify ~/.screenrc; do
screen -X source ~/.screenrc
done
Every GNU Screen user knows the frustration: you've spent time tweaking your .screenrc
file to perfection, but changes don't take effect until you restart your session. This becomes particularly annoying when you have multiple windows/tabs open with important work in progress.
GNU Screen provides a built-in way to reload configuration without session termination:
Ctrl+a :source ~/.screenrc
Or alternatively from within screen:
Ctrl+a :source $HOME/.screenrc
Let's say you've added this binding to your .screenrc
:
bindkey -k k1 select 1 # F1 switches to window 1
bindkey -k k2 select 2 # F2 switches to window 2
Instead of restarting screen, simply:
- Save the modified
.screenrc
- Execute
Ctrl+a :source ~/.screenrc
- Test your new F1/F2 bindings immediately
For power users, you can create a binding to reload config:
# Add to your .screenrc
bind R source ~/.screenrc
Now just press Ctrl+a R
to reload configurations.
- Some settings (like session/window layout) can't be changed dynamically
- New bindings will work, but existing ones won't be unbound
- Display-related settings may require window refresh
For safer testing, launch a temporary screen session:
screen -c ~/.screenrc -S testconfig
This lets you verify changes without touching your main session.