In a previous life, well, on a prev distro, i spent hours reading about .bashrc .profile … etc. Armed with that font of knowledge i packed my CLI toolkit and marched to the front line confident that i knew not only what to do but i knew where the best place to put the call to the paths i would always want.
OK, that’s a while ago, i’m old and my memory sucks, so i can’t remember exactly now what order had been recommended. What i do distinctly remember is that the first choiceS of files recommended by the articles i had read did not exist and that i ended up adding my path, well called my paths subroutine, (sorry, i still think in Fortran 3 terms) to the .bashrc file as a copout.
Is there a “preferred” or “better” way to set the pre-paths each time a terminal is started please?
N.B.
I have a single user machine, if anyone else did want to use it, i would make a new user for them and they would certainly not want/need to use CLI.
Addon Question
Does the EOS rolling update process ever update, i.e. destroy my updates, the .bashrc file … or .profile etc files?
IMHO and experience with dot files, the best place is .profile, which you should confirm it is sourced from .xprofile as well (for GUI/X apps), having a single point for such basic configuration (env vars), that are used from both CLI and GUI processes.
No system package update would touch local/user folders ever. If this is done, it is a bug. Only possible changes (for local SysAdmin) are /etc/xdg and /etc/skel/, and a couple others I would have to search for confirming (since I am also too old to remember everything and always ).
Thanks for the reply and sorry for the delay @petsam…IRL
There wasn’t a .profile on my machine at all (yes, i did set hidden files in catfish). There also isn’t an .xprofile
As my $HOME directory didn’t have a .profile file i created one and added my bits ( the line “. /home/mine/bin/udpath.sh” which echo’s the current path then adds to it and echo’s it again)
However, when i started a terminal my paths had not been added.
The line i added did work on my prev distro although i added it to .bashrc in that case (yes, the file it sources to does exist and it is unchanged from my prev distro)
There are a few checks to be made.
If I don’t see real data, my only hope is my Crystal Ball , but it’s away for summer vacations these days .
Post:
ls -na $HOME | grep -v "^d"
ls -n $HOME/bin/udpath.sh # or whatever path is your script
In short, here is one of the many ways it can be done:
# Assuming the local path I use is $HOME/.local/bin
# Add local bin path
if ! $(echo $PATH | grep -oqE "(^|:)$HOME/.local/bin($|:)") ; then
export PATH="$HOME/.local/bin:$PATH"
fi
FYI
The .profile file i created contains a source call (shown above) to this:
$ cat /home/mine/bin/udpath.sh
#!/bin/bash
# call: /home/mine/bin/udpath.sh
echo "e1" $PATH
# printf "p1 $PATH\n"
PATH="${PATH:+${PATH}:}/home/mine/bin"
echo "e2" $PATH
# printf "p2 $PATH\n"
export PATH
PATH="${PATH:+${PATH}:}/home/mine/bin/perl"
echo "e3" $PATH
# printf "p3 $PATH\n"
export PATH
#
# Adding new directory to the PATH variable for all users
# The global path can be updated by either:
# 1. Adding a new file named /etc/profile.d/mypath.sh to be run upon login for all users, containing:
# PATH=$PATH:/new_path
# (Note: This method will affect all users (existing users and future users).
#
Yes, i do tend to over document … and over simplify (i once had to return from an amazing assignment in Hong Kong to fix something in Macclesfield)
p.s.
i do agree that yours is more, shall we say, “succinct” - neater too!