Question

At the office, we have a shared user we use half the time. I'm trying to get screen to automatically load a custom bashrc file that I created for myself when using the shared user. So far I have this which works well:

alias screen='screen -d -R -S redhar -c /home/redhar/.screenrc bash -rcfile '\''/home/goldenuser/.bashrc_redhar'\'''

This works well for the very first window it creates. The problem comes when I create a new window. Is there anyway to get a newly created window to automatically use the same rcfile?

So far I have considered the following option, but I'm looking for a more streamlined solution along the lines of a missing GNU screen config option I overlooked or something. My proposed solution:

In regular .bashrc which gets loaded automatically:

if [[ $SCREENFLAG == "REDHAR" ]]
then
    . /home/goldenuser/.bashrc_redhar
    exit
fi

Set alias to:

alias screen='SCREENFLAG=REDHAR screen -d -R -S redhar -c /home/redhar/.screenrc bash -rcfile '\''/home/goldenuser/.bashrc_redhar'\'''

Was it helpful?

Solution

Discovered the solution is to create a file with

bash -rcfile /home/goldenuser/.bashrc_redhar

then set your shell command in .screenrc to it

shell='<path to file created above>'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top