dotfiles.2022/_home/dot_sz.shrc

34 lines
1.2 KiB
Plaintext

# If not running interactively, don't do anything
SFP='.sz' # Script Family Prefix
[ -z ${DBG_SHRC} ] || echo "Entered ${SFP}.shrc"
case $- in
*i*) echo "Welcome $USER to $(hostname)";;
*) return;;
esac
export SHRC_D=~/${SFP}.shrc.d
if [ -d ${SHRC_D} ]; then
script_source=("$(find ${SHRC_D} -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).pre")")
script_source+=("$(find ${SHRC_D} -maxdepth 0 -type d)")
script_source+=("$(find ${SHRC_D} -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).post")")
[ -z ${DBG_SHRC} ] || echo "Working with (${script_source[@]})..."
for script_src in ${script_source[@]}; do
scripts=($(find $script_src -maxdepth 1 -type f -not -name "*~" -not -name "*.off" -not -name "*.swp" | sort))
#[ -z ${DBG_SHRC} ] || echo "Within $script_src, will review (${scripts[@]})..."
for script_name in ${scripts[@]}; do
[ -z ${DBG_SHRC} ] || echo "Checking $script_name..."
if [ -r $script_name ]; then
[ -z ${DBG_SHRC} ] || echo "Sourcing $script_name..."
. $script_name
fi
done
unset scripts
unset script_name
done
unset script_source
fi
[ -z ${DBG_SHRC} ] || echo "Exiting ${SFP}.shrc"