sskras / .files

Personal attempt at automating setup of a new home dir / managing dot-files in a cross-platform way.
Other
1 stars 0 forks source link

PATH customizations from .bashrc get duplicated in new Bash sessions #1

Open sskras opened 9 months ago

sskras commented 9 months ago

If I log in via SSH, the PATH gets some defaults + my additions from .profile and .bashrc:

sskras@vps1128235:~$ echo "${PATH//:/$'\n'}"
/home/sskras/.local/bin
/home/sskras/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
/home/sskras/pkg/bin
/home/sskras/pkg/sbin

But if I launch new interactive session from the old one, my customizations get duplicated:

sskras@vps1128235:~$ bash -l
Executing /home/sskras/.profile
Executing /home/sskras/.bashrc
Executing /home/sskras/.bash_aliases
Executing /home/sskras/.bash_functions

sskras@vps1128235:~$ echo "${PATH//:/$'\n'}"
/home/sskras/.local/bin
/home/sskras/bin
/home/sskras/.local/bin
/home/sskras/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
/home/sskras/pkg/bin
/home/sskras/pkg/sbin
/home/sskras/pkg/bin
/home/sskras/pkg/sbin

(Eg. the starting and the ending dirs)

If would be nice to keep PATH customizations but avoid repeating the added dirs on every new interactive session.

sskras commented 9 months ago

That would probably require having a PATH-manager which does dedup instead of a manual concatenation.

To be readily available on a bootstrap, the manager should be a shell script. Preferably Bourne-like/POSIX shell script (for staying cross-platform).