aliases Lost When Using screen
Not sure if this is Slack related or not, but I thought I'd post here first.
The "vanilla" Slack 12.2 I'm using sets up 3 or 4 aliases when I log on, particularly the one to colourise ls. When I start a "screen" session, it appears that my current profile is used by screen, with the exception of TERM=, which I think is normal. However, all the aliases that are currently set, are gone. Is this normal. Cheers. |
Yes. Aliases are particular to a given shell instance. They are not inherited when you launch a subshell. Screen launches a new shell and, probably not being a login shell, it doesn't have any of those aliases as the files that create them are not read when the shell is launched. Add a line like this one to your ~/.screenrc:
Code:
shell -$SHELL |
Quote:
Everything else that is set up by /etc/profile is in place though, which I'm guessing is because it's inherited from the "launching" shell. So, why not aliases as well. BTW, that command made no difference, nor did -${SHELL}. I still don't have the aliases in screen. Cheers. |
Does "shell -/bin/bash" make any difference?
|
Nope.
Cheers. |
aliases lost when using screen, not sourcing profile
Like the user who started this thread, I'm using Slackware 12.2 and have the same problem when I run screen. I have tried specifying the path to bash, as suggested above.
I've also tried specifying /bin/bash at the command line with the -s option (screen -s /bin/bash). Once I'm in screen, I can add aliases to the environment from the command line, or manually source /etc/profile and that will give me my aliases. I was reading on a blog at http://www.lornajane.net/posts/2008/Screen-for-Linux and it's mentioned that the shell command command works for her to give her aliases. And I have a friend who started up screen for me on his distro of PCLinuxOS, aliases included there too. As for one more person this isn't working for, another web page ( http://www.linux-archive.org/centos/...ng-bashrc.html ) where someone says screen isn't sourcing his ~/.bashrc file, apparently a CentOS user. Part of the reply to him states: Quote:
This is what my ~/.screenrc file looks like. It's almost a duplicate of the default one when installing screen on Slackware. I've not made any changes, and the only additions I've made are the last two lines. Code:
# |
What I find extremely odd about this is that most of the aliases I've defined are in /etc/profile.d/custom.sh, a file which is definitely getting read when I invoke a screen session. I know this because the custom environmental variables I've defined in custom.sh are set into my screen session when screen is invoked.
And then once I'm in the screen session, executing 'source /etc/profile' will do what it's supposed to do: read in /etc/profile and then whatever's in /etc/profile.d/. At that point, my aliases which are in custom.sh finally are added to my screen session environment. So essentially, it seems the aliases are ignored the first time but not the second time, for no apparent reason. Here's an excerpt from custom.sh: Code:
alias cls="clear" |
I find it very weird that it fails for you. I start screen normally using /usr/bin/screen -A -D -R. I don't have a .bashrc or .bash_profile files. I do have a $HOME/.profile file that sets up some environment variables and custom aliases, but it doesn't re-source /etc/profile or anything similar. My $HOME/.screenrc is copied below. Even though /etc/profile is not re-sourced from my shell startup files, I do get the system aliases in my shell session inside screen. For example, the alias
Code:
alias dir='/bin/ls $LS_OPTIONS --format=vertical' Code:
# |
Quote:
Using your command line options and a copy of your screenrc (into ~/.screenrc, and after creating the symlink ~/.profile -> ~/.bash_profile, I get the same result. No aliases, unless I source /etc/profile after I'm in screen. Of course that only applies it to my current screen window. Are you using Slackware? The user who started this post is a Slackware user, and I am. |
Yes, I've been running slackware-current for years, and it has always worked for me.
|
I had this problem too, what fixed it for me was adding the "shell -$SHELL" line.
Naturally you might just try to append this to the file. This won't work, however, if you create screens inside the .screenrc file. It must be added BEFORE any screens are created in the .screenrc file: Code:
shell -$SHELL |
All times are GMT -5. The time now is 10:05 AM. |