Add base configuration

- Follow XDG standard: ~/.config and ~/.local folders
- Set environment variables and define aliases within ~/.config/shell
- Add installation script for easy setup and maintenance
  (i.e., `dotfiles-install` and `dotfiles-update`)
- Add README.md with info on the installation and general notes
This commit is contained in:
Alexander Hess 2026-06-11 18:28:00 +02:00
commit a89c4955c5
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
13 changed files with 583 additions and 0 deletions

83
.profile Normal file
View file

@ -0,0 +1,83 @@
#!/bin/sh
# Main setup file executed for all kinds of shells
# Prevent loading ~/.profile twice in `bash`
export PROFILE_LOADED=1
# 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 # Ignore non-existing directories
case :$PATH: in
*:"$1":*) ;; # Already in the `$PATH` => Do nothing
*) PATH=$1:$PATH ;; # Otherwise, prepend it
esac
fi
}
_remove_from_path () {
_rest=$PATH # Not yet processed `$PATH`s
_new= # `$PATH`s collected so far
while [ -n "$_rest" ]; do # Rebuild the `$PATH` entry by entry
_dir=${_rest%%:*} # First remaining entry
case $_rest in
*:*) _rest=${_rest#*:} ;; # Drop that entry and its colon
*) _rest= ;; # Last entry read => Stop
esac
[ "$_dir" = "$1" ] && continue # Skip on an exact match
_new=${_new:+$_new:}$_dir # Append, avoiding a leading colon
done
PATH=$_new
unset _dir _new _rest
}
_remove_from_path "/usr/games"
_remove_from_path "/usr/local/games"
_prepend_to_path "$HOME/.local/bin"
# Needs ~/.local/bin on the `$PATH` already
# because it checks existence of some binaries
[ -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
if [ -n "$BASH_VERSION" ] && [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
# Ensure ~/.profile is loaded each time `bash` starts
unset PROFILE_LOADED