dotfiles/.bashrc

84 lines
1.1 KiB
Bash
Raw Permalink Normal View History

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