dotfiles/.bashrc

83 lines
1.1 KiB
Bash

###
# Disable rc file in non-interactive mode.
###
if [[ $- != *i* ]]; then
return
fi
###
# Apply default environment.
###
__dotlib_set_PATH() {
local path paths=("$HOME"/bin {/usr{/local,},}/{,s}bin)
printf -v path %s: "${paths[@]}"
export PATH=${path%:}
}
__dotlib_set_ENV() {
local var
declare -A env=(
[EDITOR]=nano
[PAGER]=less
[LESSHISTFILE]=-
[HISTCONTROL]=ignoreboth
[XDG_CONFIG_HOME]=~/.config
[LESSHISTSIZE]=0
)
for var in "${!env[@]}"; do
export "$var"="${env[$var]}"
done
}
__dotlib_set_SHOPTS() {
local shopts=(
{null,ext,dot}glob globstar cmdhist
hostcomplete checkwinsize checkhash
)
shopt -s "${shopts[@]}"
}
__dotlib_set_PATH
__dotlib_set_ENV
__dotlib_set_SHOPTS
ulimit -c unlimited
###
# Load the dot library.
###
__dotlib_load_libraries() {
local os dot{,s}
case $OSTYPE in
darwin*)
os=darwin
;;
*)
os=unknown
esac
dots=(
~/.config/dotlib/pre/*.sh
~/.config/dotlib/"$os"/*.sh
~/.config/dotlib/post/*.sh
)
for dot in "${dots[@]}"; do
. "$dot"
done
}
__dotlib_load_libraries
###
# Reset the exit status.
###
true