I've been creating a project for managing my complete terminal environment. One of the things I manage are the dotFiles. So I have separate dotfiles for e.g.
- ivonet-alias.sh
- ivonet-docker.sh
- ivonet-functions.sh
- etc.
When I run setup.sh from my project I install symlinks (ln
) to my ivonet-*.sh files in my HOME folder. Now to activate them I do the following (once):
prefix="ivonet"
resource="${HOME}/.zshrc"
echo "" >>${resource}
echo "# Personal dotFile resources:" >>${resource}
echo "for f in \${HOME}/.${prefix}-*.sh; do source \${f}; done" >>${resource}
On my own machine I use oh-my-zsh shell and I make it so that that file is changed so that when I open a new terminal session all my dotfiles are source
d in. This works fine but now a couple of colleagues asked to use my setup for dotfiles too and I gave them my repo and it didn't work as I had hoped. The were not using zsh but bash, but even that was not uniform.
When I changed the setup to write to .bashrc
it worked for one colleague but not for the other. So in the end I had to do it multiple ways.
- once in
.profile
- twice in
.bash_profile
- once in
.bashrc
Can anyone help me on how I can determine where to make the changes?
I would like to be able to check this from a script something like:
check=$(which bash)
if [[ -z "${check}" ]]; then
#do stuff here
fi
but I have no idea how to do this. I know it looks like this whats-the-difference-between-bashrc-bash-profile-and-environment but I'm more interested on how I can automatically determine which file is loaded.