Am Mittwoch, 26. Februar 2020, 21:12:37 CET schrieb Andrei Borzenkov:
26.02.2020 19:18, Hans-Peter Jansen пишет:
Hi,
The idea is to throw a file into /etc/profiles.d/ and have everything available in every users environment without any specific ~/.profile or ~/.bashrc tweaking.
Specifically, I want to define PS1, aliases and some functions.
Unfortunately it doesn't work as advertised.
Here's a subset of my trial (please ignore for now the way, I define the PS1 colors here, it should work in most terminals):
cat > /etc/profile.d/test.sh << EOF # shell prompt if [ -n "$BASH_VERSION" ]; then
set -P set -p if [ "$UID" = 0 ]; then
PS1='\[\033[1;32m\]\h\[\033[1;36m\]:\[\033[1;31m\]\w\[\033[0;33m\] #\[\033[0m\] '> else
PS1='\[\033[1;32m\]\u\[\033[0;36m\]@\[\033[1;32m\]\h\[\033[1;36m\] :\[\033[1;31m\]\w\[\033[0;33m\]>\[\033[0m\] '> fi export PS1
fi
alias vi='vi -o'
Aliases should be available for each interactive shell which means progile is simply the wrong place to set them.
I see, it that documented somewhere?
psg () {
if [ $# -le 0 ]; then
ps auxww | less
else
ps auxww | egrep "$@" | grep -v grep
fi
}
export repo=/etc/zypp/repos.d EOF
In theory, these should be available in every users environment.
$repo is, the rest is not.
You do not say how user logs in, so it is rather hard to answer. Assuming you mean GUI session - /etc/profile is sourced by session script, which means only exported variables or functions are available in later subshells. Also depending on your exact DE environment may be inherited via systemd/D-Bus which may simply ignore exported functions which leaved only exported variables.
Okay, sorry for omitting that important information. Yes, my primary target are DEs with KF5, running konsole.
After "su - $USER" or login via ssh all is well?!? Puzzled.
So, there seems to be some environment tidying happen behind the scenes. Of course, I studied /etc/profile, /etc/bash.bashrc, and I can source this from ~/.bashrc. It will also not work, when sourced from ~/.profile.
It might be, that PS1 is redefined from /etc/bash.bashrc, but why does it work from su - $USER or ssh then?
Again, you do not say how you log in, but - PS1 is set only in interactive shells. For GNOME what happens is - gnome-session re-executes itself under login shell. This login shell exports PS1. Then gnome-session shebang shell unsets PS1 because it is non-interactive. gnome-session-binary uploads current environment into systemd which is where it comes from for your interactive gnome-terminals.
Sounds complicated, but I suspect something similar obscure is going on for KF5 and konsole sessions. The here script from my initial submission allows inclined people to test this behavior themselves easily. I also see places in the initial scripts (/etc/profile and /etc/bash.bashrc, that specifically deal with the ssh login special case. I don't see similar obvious handling of, say su - handling, but both get it right, while konsole sessions do not. Again, my primary goal is supplying such system configuration at *one* place for all users and any DE (with focus on konsole), but failed to do so with *any* of the given possibilities including /etc/profile.local - without the need to adjust each and every user's .bashrc. Thanks for the insight, Andrei, much appreciated. Unfortunately, I still don't see any strategy, that might be successful. Any other ideas, how to archive that goal? Thanks, Pete -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org