2026-06-11 18:28:00 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# Main setup file executed for all kinds of shells
|
2026-06-11 18:28:02 +02:00
|
|
|
#
|
|
|
|
|
# For `bash`, if the following files exist,
|
|
|
|
|
# they have precedence over this file:
|
|
|
|
|
# - ~/.bash_login
|
|
|
|
|
# - ~/.bash_profile
|
|
|
|
|
#
|
|
|
|
|
# So, we make both source this file,
|
|
|
|
|
# and thus preserve the load order either way!
|
2026-06-11 18:28:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Prevent loading ~/.profile twice in `bash`
|
2026-06-11 18:28:02 +02:00
|
|
|
PROFILE_LOADED=1
|
2026-06-11 18:28:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Basic utilities
|
|
|
|
|
|
|
|
|
|
_command_exists() {
|
|
|
|
|
command -v "$1" 1>/dev/null 2>&1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_in_bash() {
|
|
|
|
|
[ -n "$BASH_VERSION" ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_in_zsh() {
|
|
|
|
|
[ -n "$ZSH_VERSION" ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_prepend_to_path () {
|
|
|
|
|
if [ -d "$1" ] ; then
|
|
|
|
|
case :$PATH: in
|
|
|
|
|
*:$1:*) ;;
|
|
|
|
|
*) PATH=$1:$PATH ;;
|
|
|
|
|
esac
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Load configuration files common to all kinds of shells
|
|
|
|
|
[ -f "$HOME/.config/shell/env" ] && . "$HOME/.config/shell/env"
|
|
|
|
|
[ -f "$HOME/.config/shell/aliases" ] && . "$HOME/.config/shell/aliases"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Source ~/.profile_local, which holds machine-specific ENV variables
|
|
|
|
|
[ -f "$HOME/.profile_local" ] && . "$HOME/.profile_local"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Load `bash`-specific configurations for non-login `bash` shells
|
|
|
|
|
if [ -n "$BASH_VERSION" ] && [ -f "$HOME/.bashrc" ]; then
|
|
|
|
|
. "$HOME/.bashrc"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
2026-06-11 18:28:02 +02:00
|
|
|
# `zsh`-specific configurations are automatically sourced from ~/.zshrc,
|
|
|
|
|
# which then also ensures that this file is sourced
|
|
|
|
|
|
|
|
|
|
|
2026-06-11 18:28:00 +02:00
|
|
|
# Put local executables on the `$PATH`
|
|
|
|
|
_prepend_to_path "$HOME/.local/bin"
|
2026-06-11 18:28:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# When everything is loaded, show a little welcome message
|
|
|
|
|
case $- in *i*) [ -f "$HOME/.config/shell/welcome" ] && . "$HOME/.config/shell/welcome";; esac
|