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.
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.
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.
psg() most definitely isn't redefined anywhere else.
Anybody out there, who can shed some light into this issue would be much appreciated.
Thanks in advance, Pete
-- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org