dotfiles.2022/_home/dot_sz.shrc

52 lines
2.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# If not running interactively, don't do anything
SFP='.sz' # Script Family Prefix
[ -z ${DBG_SHRC} ] || echo "Entered ${SFP}.shrc"
export SHRC_D=~/${SFP}.shrc.d
unset SHLVL_${SFP##*.}
IS_INTERACTIVE=${IS_INTERACTIVE:-$-}
# himBHs - Interactive
# hBc - called with `bash -c`
# h Locate and remember (hash) commands as they are looked up for
# execution. This option is enabled by default.
# i Interactive shell.
# m Job control is enabled (see Job Control). All processes run in a
# separate process group. When a background job completes, the
# shell prints a line containing its exit status.
# c Commands were supplied from via `bash -c` command line switch.
# B The shell will perform brace expansion (see Brace Expansion).
# This option is on by default.
# H Enable ! style history substitution (see History Interaction).
# This option is on by default for interactive shells.
# s Read commands from the standard input.
case $IS_INTERACTIVE in
*i*) echo "Welcome $USER to $(hostname)";;
FORCE) ;;
*) return;;
esac
unset IS_INTERACTIVE
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"