Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

preserve my env in linux screen

I have serveral customized environment variables and functions in my ~/.bash_profile which I would like to be called automatically when I start my screen session with screen -D -R, but apparently adding source ~/.bash_profile in ~/.screenrc doesn't solve my issue.

On every new screen I have to manually source the bash_profile.

I have noticed that this file can't be found while creating a new screen (when you create new screen there is the the line in the bottom showing what commands are executing and it returns that the file can't be found.)

like image 712
Amir Avatar asked Dec 26 '22 01:12

Amir


1 Answers

~/.bash_profile is only run by login shells.

~/.bashrc is run by other interactive shells, such as those started by screen.

~/.screenrc is a screen configuration file, and is not used to configure bash.

Put things that should be set up per shell in ~/.bashrc, and add source ~/.bashrc to your ~/.bash_profile.

like image 200
that other guy Avatar answered Jan 04 '23 21:01

that other guy