I also have multiple versions of by bash_profile with syntax specific to the OS. It checks if we're on MacOS or Linux with a kernel check and then reads the appropriate ancillary bash_profile for that platform. Anything that can live in the main bash_profile with the same command on both platforms lives there and anything that needs to be system-specific is in the other one.
I have all my important functions as individual files that get loaded with the following:
function loadfuncs() {
local funcdir="$HOME/.dotfiles/functions/"
[ -e "${funcdir}".DS_Store ] && rm "$HOME/.dotfiles/functions/.DS_Store"
local n=0
for i in "${funcdir}"*; do
source "$(realpath $i)"
n=$(( n + 1 ))
done
}
loadfuncs
Interesting way to go about it. Though when I'm at the point where I need differences between linux and darwin, I'm probably going to do that at the home-manager level.