I have a couple thoughts on this. First, note you can control the startup screenrc when invoking screen via the -c
command line switch. Second, you can use environment variables in your .screenrc. Putting this all together, here's a shell script to do something like what you want:
#!/bin/bash
cat << EOF >/tmp/screenrc.$$
logfile /tmp/screenlog.$$
EOF
screen -c /tmp/screenrc.$$ -L
rm /tmp/screenrc.$$
echo "logfile is /tmp/screenlog.$$"
that script overrides the user screenrc and places the output in a specific file. In this case I'm using $$
to generate the file name by appending the script process name. Note that you should generally use mktemp
instead to create secure temporary files but I'm lazy right now.
Also this completely replaces the user .screenrc
. If you want to still read settings from that file, you should change the generated config file to something like this:
logfile /tmp/screenlog.$$
source $HOME/.screenrc