You are not logged in.

#1 2009-10-17 12:39:27

dabd
Member
Registered: 2008-11-17
Posts: 109

.screenrc does not source .bashrc

Hi,

My screenrc does not source my bashrc.
I put the line 'shell -$SHELL' on my screenrc to make every screen shell a login shell.
My ~/.bash_profile is sourcing my ~./bashrc which defines some alias which I would like to use.

Thanks.

Last edited by dabd (2009-10-17 12:40:14)

Offline

#2 2009-10-17 17:09:57

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: .screenrc does not source .bashrc

Perhaps the $SHELL var isn't evaluated?  I use this line in .screenrc to do the trick:

defshell -bash      # dash makes it a login shell

thayer williams ~ cinderwick.ca

Offline

#3 2009-10-17 19:05:59

dabd
Member
Registered: 2008-11-17
Posts: 109

Re: .screenrc does not source .bashrc

thayer wrote:

Perhaps the $SHELL var isn't evaluated?  I use this line in .screenrc to do the trick:

defshell -bash      # dash makes it a login shell

I tried your way but it doesn't work either. I am baffled!
Thanks.

Offline

#4 2009-10-17 19:18:19

dabd
Member
Registered: 2008-11-17
Posts: 109

Re: .screenrc does not source .bashrc

The line in screenrc that's causing me problems reads as:

screen -t shell  4 sshtunnel

where sshtunnel is an alias I defined in bashrc

According to the screen manual http://www.gnu.org/software/screen/manu … -screen-16
the screen command syntax

 screen [opts] [n] [cmd [args]]

expects a cmd.  Is it valid to specify an alias or it has to be some cmd in your $PATH?

Thanks.

Offline

#5 2009-10-17 20:26:07

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: .screenrc does not source .bashrc

dabd wrote:

The line in screenrc that's causing me problems reads as:

screen -t shell  4 sshtunnel

where sshtunnel is an alias I defined in bashrc

The problem is with the alias. As man bash states:

Aliases  are  not  expanded  when  the  shell  is  not  interactive, unless the  expand_aliases shell option is set using shopt (see the  description  of  shopt under SHELL BUILTIN COMMANDS below).

Thus screen does not know of the alias when it reads .screenrc, because the shell it reads is not interactive.


To know or not to know ...
... the questions remain forever.

Offline

#6 2009-10-17 21:22:51

dabd
Member
Registered: 2008-11-17
Posts: 109

Re: .screenrc does not source .bashrc

I ditched the alias and created a function in bashrc instead but it didn't work because it seems that bash doesn't export functions to other shells.
So I created a script in my ~/bin that just does what my alias did and problem solved!
If there is a more elegant solution I would be grateful to know about it.

Thanks.

Offline

Board footer

Powered by FluxBB