dotfiles.2022/_home/dot_sz.shrc

52 lines
2.0 KiB
Plaintext
Raw Permalink Normal View History

# If not running interactively, don't do anything
2022-09-29 22:29:13 +00:00
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) ;;
2022-09-29 22:29:13 +00:00
*) return;;
esac
unset IS_INTERACTIVE
2022-09-29 22:29:13 +00:00
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
2022-06-20 02:42:37 +00:00
scripts=($(find $script_src -maxdepth 1 -type f -not -name "*~" -not -name "*.off" -not -name "*.swp" | sort))
2022-09-29 22:29:13 +00:00
#[ -z ${DBG_SHRC} ] || echo "Within $script_src, will review (${scripts[@]})..."
for script_name in ${scripts[@]}; do
2022-09-29 22:29:13 +00:00
[ -z ${DBG_SHRC} ] || echo "Checking $script_name..."
if [ -r $script_name ]; then
2022-09-29 22:29:13 +00:00
[ -z ${DBG_SHRC} ] || echo "Sourcing $script_name..."
. $script_name
fi
done
unset scripts
unset script_name
done
unset script_source
fi
2022-09-29 22:29:13 +00:00
[ -z ${DBG_SHRC} ] || echo "Exiting ${SFP}.shrc"