[arch-dev-public] System-wide bashrc?
This problem has been bugging me for some time: /etc/profile is only read for login-shells. That is fine, because you launch a login-shell once, then start your graphical environment from it. Most of the environment is persisitent so that it will appear in X terminals (which only launch interactive non-login shells). However, if you launch an interactive shell, the following is lost: * PS1, PS2 * all aliases * /etc/bash_completion So, I have to set up the bashrc of every user to restore PS1, PS2, my custom aliases and bash_completion. Is there a solution to this is in something like a "system-wide bashrc"? The current way is really inconvenient.
Thomas Bächler wrote:
This problem has been bugging me for some time: /etc/profile is only read for login-shells. That is fine, because you launch a login-shell once, then start your graphical environment from it. Most of the environment is persisitent so that it will appear in X terminals (which only launch interactive non-login shells).
However, if you launch an interactive shell, the following is lost: * PS1, PS2 * all aliases * /etc/bash_completion
So, I have to set up the bashrc of every user to restore PS1, PS2, my custom aliases and bash_completion. Is there a solution to this is in something like a "system-wide bashrc"? The current way is really inconvenient.
Maybe do something like this? /usr/bin/bash2: #!/bin/bash bash --rcfile /etc/bashrc and then echo "/usr/bin/bash2" >> /etc/shells usermod -s /usr/bin/bash2 myuser Glenn
RedShift schrieb:
/usr/bin/bash2: #!/bin/bash bash --rcfile /etc/bashrc
and then
echo "/usr/bin/bash2" >> /etc/shells usermod -s /usr/bin/bash2 myuser
Yes, or create /etc/bashrc, then /etc/bashrc.d/ and allow to move files there just like /etc/profile.d. But then you'd need ". /etc/bashrc" in all user ~/.bashrc. I was hoping there was some magical mechanism that would apply systemwide.
Thomas Bächler wrote:
RedShift schrieb:
/usr/bin/bash2: #!/bin/bash bash --rcfile /etc/bashrc
and then
echo "/usr/bin/bash2" >> /etc/shells usermod -s /usr/bin/bash2 myuser
Yes, or create /etc/bashrc, then /etc/bashrc.d/ and allow to move files there just like /etc/profile.d.
I was only illustrating the idea I had about how I would fix it, shouldn't be much hassle to add the features you're talking about.
But then you'd need ". /etc/bashrc" in all user ~/.bashrc.
That's problem I've just solved by using a custom shell script that wraps around bash?
I was hoping there was some magical mechanism that would apply systemwide.
Not according to the manpage. I wonder why they haven't built in a feature like this, seems pretty trivial to me... I still like my solution though, because it allows you to select which users adhere to /etc/bashrc and which not. For example, for root it may have unexpected consequences due to what's being read from /etc/bashrc. Glenn
On Tue, Aug 25, 2009 at 11:30 AM, RedShift<redshift@pandora.be> wrote:
Thomas Bächler wrote:
RedShift schrieb:
/usr/bin/bash2: #!/bin/bash bash --rcfile /etc/bashrc
and then
echo "/usr/bin/bash2" >> /etc/shells usermod -s /usr/bin/bash2 myuser
Yes, or create /etc/bashrc, then /etc/bashrc.d/ and allow to move files there just like /etc/profile.d.
I was only illustrating the idea I had about how I would fix it, shouldn't be much hassle to add the features you're talking about.
But then you'd need ". /etc/bashrc" in all user ~/.bashrc.
That's problem I've just solved by using a custom shell script that wraps around bash?
I was hoping there was some magical mechanism that would apply systemwide.
Not according to the manpage. I wonder why they haven't built in a feature like this, seems pretty trivial to me... I still like my solution though, because it allows you to select which users adhere to /etc/bashrc and which not. For example, for root it may have unexpected consequences due to what's being read from /etc/bashrc.
Glenn
you could modify the files in /etc/skel. These files are used as a template when creating a new user, not sure if it helps you with existing users though. Ronald
On Tue, Aug 25, 2009 at 3:27 AM, Thomas Bächler<thomas@archlinux.org> wrote:
This problem has been bugging me for some time: /etc/profile is only read for login-shells. That is fine, because you launch a login-shell once, then start your graphical environment from it. Most of the environment is persisitent so that it will appear in X terminals (which only launch interactive non-login shells).
However, if you launch an interactive shell, the following is lost: * PS1, PS2 * all aliases * /etc/bash_completion
So, I have to set up the bashrc of every user to restore PS1, PS2, my custom aliases and bash_completion. Is there a solution to this is in something like a "system-wide bashrc"? The current way is really inconvenient.
Hmm, you could sidestep the issue by forcing your X terminals to launch login shells. I use: urxvt*loginShell: true
Aaron Griffin schrieb:
Hmm, you could sidestep the issue by forcing your X terminals to launch login shells. I use: urxvt*loginShell: true
Doesn't work for all terminals and is not really intended. And starting a login shell takes quite a while. I used to do it this way in the past though. Note that you only need a small subset of the commands in /etc/profile.
On Tue, Aug 25, 2009 at 10:28 AM, Thomas Bächler<thomas@archlinux.org> wrote:
Aaron Griffin schrieb:
Hmm, you could sidestep the issue by forcing your X terminals to launch login shells. I use: urxvt*loginShell: true
Doesn't work for all terminals and is not really intended. And starting a login shell takes quite a while. I used to do it this way in the past though. Note that you only need a small subset of the commands in /etc/profile.
Well even if it takes a while, it solves the config-file issue :) I guess I don't start too many terminals in rapid-fire succession. This here seems to indicate there is a SYS_BASHRC compile time option: http://osdir.com/ml/bug-bash-gnu/2009-05/msg00037.html I'll look into it
On Tue, Aug 25, 2009 at 10:33 AM, Aaron Griffin<aaronmgriffin@gmail.com> wrote:
On Tue, Aug 25, 2009 at 10:28 AM, Thomas Bächler<thomas@archlinux.org> wrote:
Aaron Griffin schrieb:
Hmm, you could sidestep the issue by forcing your X terminals to launch login shells. I use: urxvt*loginShell: true
Doesn't work for all terminals and is not really intended. And starting a login shell takes quite a while. I used to do it this way in the past though. Note that you only need a small subset of the commands in /etc/profile.
Well even if it takes a while, it solves the config-file issue :) I guess I don't start too many terminals in rapid-fire succession.
This here seems to indicate there is a SYS_BASHRC compile time option: http://osdir.com/ml/bug-bash-gnu/2009-05/msg00037.html
I'll look into it
And committed to trunk. Our bash should now support /etc/bashrc and /etc/bash.logout when it's rebuilt I believe Thomas is going to add a default system-wide bashrc for non-login shells
participants (4)
-
Aaron Griffin
-
RedShift
-
Ronald van Haren
-
Thomas Bächler