Default GNU screen "screens"
You can define default windows in your Screen configuration file, ~/.screenrc
.
Window titles can be set inline with the -t
option, but working directories must be set in advance of launching each window. For example, in your case you might include the following:
~/.screenrc
# ...
chdir ~
screen -t "Htop" htop
chdir /var/log
screen -t "System log" tail -F syslog
screen -t "Mail log" tail -F mail.log
chdir ~
screen # Extra Bash window for running commands
# ...
Note that the screen
here is not the screen
command you run, but an internal screen
command. See man screen
, section on Customization, or the GNU manual for more.
You could take advantage of the -S
flag, and provide a unique name you'd like to give the screen.
screen -S MyTitleHere
You can also load configuration files, using the -c
flag.
screen -S foo -c /home/user/.screenrc.bar
You could try something such as:
su -c "screen -dm -S $TITLE 2>&1 1>/dev/null" $USER
And place it in your /etc/rc.local
, which would cause that screen to be created when you boot up for a specific user.
Once you get your configuration (.rc
) files set up, you'll probably want to run something along the lines of:
screen -dURS $TITLE -c /path/to/.screenrc.bar
As this will
- Create the screen session if it doesn't exist
- Re-Attach to the session if it already exists.
Another option would be to use tmux
and tmuxinator
, which provide a cleaner experience, in my opinion. You can set up tmux
to use the screen-style keybindings, if you're used to that. I say this because I've had much better success running tmux
for other users than I have had with screen.