Originally Posted by Himilhil
I want to have an ls' output colorization in gnu screen. Colorization in my system (Slackware 13) is realized by aliasing of ls in /etc/profile.d/coreutils-dircolors.sh:
$ alias ls
alias ls='/bin/ls $LS_OPTIONS'
where $LS_OPTIONS is
$ echo $LS_OPTIONS
-F -T 0 --color=auto
But in screen this alias isn't defined. It seems like /etc/profile script isn't executed at shell starting in screen. I think it happens because screen starts a shell not as a login shell. I tried to correct it by adding
to ~/.screenrc or to /etc/screenrc. The problem is the same. By the way when I start screen as a root I haven't this problem. What's wrong?
Non-login shells are necessarily descendant processes of a login ancestor shell in the normal interactive working environment. Thus they inherit anything exported when the login shell ran /etc/profile (and not unset after then). AFAIK this does not include aliases and is one of the reasons for preferring functions over aliases, because functions can be exported.
The conventional solution to this issue is to define aliases in ~/.bashrc and source ~/.bashrc from within /etc/profile
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
Another solution in this particular case would be to source /etc/profile.d/coreutils-dircolors.sh from within ~/.bashrc.
As grail suggested, the root discrepancy may lie in specifics of root's bash startup files or you may be running a login shell when starting a terminal session for root (a very Good Thing for security).
Documentation on bash startup files here