Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GNU Screen running a bash init script

I'm sure there is an answer to this in the manual to screen, but I can't find it! I want the bash shell spawned by GNU screen to source in a file in addition to the .bashrc that it already runs.

I can't put a call to the file in .bashrc because on our site .bashrc files get regenerated automatically on login.

Any ideas?

EDIT:

I created this little script (screen_bash.sh):

bash --rcfile ~/.screen_bashrc

Then added

shell $HOME/screen_bash.sh

To my .screenrc

The ~/.screen_bashrc file was

<my_setup_stuff>
export SHELL=bash

The SHELL=bash is necessary so that programs like vim can launch sub-shells correctly.

like image 607
Greg Reynolds Avatar asked Jun 12 '09 08:06

Greg Reynolds


2 Answers

Do you want this file to be sourced every single time a new screen window is opened? If so, the shell command allows you to overwrite what is run when you create a new screen window (by default it's just $SHELL). You can set this to be a script of your choice that at the end runs your shell.

like image 60
swampsjohn Avatar answered Oct 18 '22 04:10

swampsjohn


screen bash --rcfile yourfile.rc

yourfile.rc should source .bashrc.

EDIT: This doesn't really do what you want, I just realised you probably want it to apply to all shells started by screen.

like image 42
Michiel Buddingh Avatar answered Oct 18 '22 06:10

Michiel Buddingh