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

14
.config/shell/README.md Normal file
View file

@ -0,0 +1,14 @@
# Shell-related Configurations
This folder contains files that are sourced by `bash` and `zsh`.
They are not executable.
The `#!/bin/sh` line documents the dialect for readers and editors;
it has no effect, since the files are sourced and never run directly.
[`aliases`](./aliases),
[`env`](./env),
[`logout`](./logout), and
[`welcome`](./welcome)
depend on helper functions defined in [`~/.profile`](../../.profile),
so they cannot work standalone.

55
.config/shell/aliases Normal file
View file

@ -0,0 +1,55 @@
#!/bin/sh
# Aliases used in all kinds of shells
# Manage the bare `git` repository in ~/ holding the dotfiles
alias dotfiles='git --git-dir=$DOTFILES_DIR --work-tree=$HOME'
alias path='echo $PATH | tr ":" "\n"'
# Easier `cd` movements
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
# Use human-readable sizes
alias df='df --human-readable'
alias du='du --human-readable'
alias free='free --human'
# Make the terminal more colorful
alias diff='diff --color=auto'
alias grep='grep --color=auto --exclude-dir=.git'
alias ip='ip -color=auto'
if _command_exists dircolors; then
# Compute `$LS_COLORS` only once because this file is also sourced
# by every non-interactive `bash` via `$BASH_ENV` (e.g., ":!cmd" in `vi`)
if [ -z "${LS_COLORS:-}" ]; then
if [ -r "$XDG_CONFIG_HOME/dircolors" ]; then
eval "$(dircolors -b "$XDG_CONFIG_HOME/dircolors")"
else
eval "$(dircolors -b)"
fi
fi
alias ls='ls --color=auto'
fi
# Add common `ls` utilities
alias l='ls --classify --format=vertical'
alias la='ls --classify --format=vertical --almost-all'
alias lal='ls --classify --format=long --almost-all'
alias ll='ls --classify --format=long'
alias lla='lal'

52
.config/shell/env Normal file
View file

@ -0,0 +1,52 @@
#!/bin/sh
# Environment variables for all kinds of shells
# Standard XDG base directories
# See: https://wiki.archlinux.org/title/XDG_Base_Directory
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
# Make up a XDG directory for binaries (that does not exist in the standard)
export XDG_BIN_HOME="$HOME/.local/bin"
# Convenient names for various places in the system,
# shown here not only to be used but also document things
export DOTFILES_DIR="$XDG_DATA_HOME/dotfiles"
export DOTFILES_HTTPS="https://code.webartifex.de/alexander/dotfiles"
export DOTFILES_SSH="git@git.webartifex.de:alexander/dotfiles.git"
# Generic shell configs
# Fall back to a widely known terminal type
# if this host lacks the terminfo entry for `$TERM`
# (e.g., `alacritty` over `ssh` on a fresh server)
if _command_exists infocmp && ! infocmp "$TERM" >/dev/null 2>&1; then
export TERM=xterm-256color
fi
[ -t 0 ] && export GPG_TTY=$(tty)
export EDITOR=nano
export PAGER=less
export LESS="--chop-long-lines --ignore-case --LONG-PROMPT --no-init --quit-if-one-screen --RAW-CONTROL-CHARS --status-column"
[ -f "$XDG_CONFIG_HOME/shell/locale" ] && . "$XDG_CONFIG_HOME/shell/locale"
# Move common tools' config and cache files into XDG directories
export LESSHISTFILE="$XDG_STATE_HOME/less/history"

24
.config/shell/locale Normal file
View file

@ -0,0 +1,24 @@
#!/bin/sh
# Locale settings for headless machines
# Drop what a client may forward over `ssh`,
# because `AcceptEnv LANG LC_*` may be set in /etc/ssh/sshd_config
unset \
LC_ALL \
LC_ADDRESS \
LC_COLLATE \
LC_CTYPE LC_IDENTIFICATION \
LC_MEASUREMENT \
LC_MESSAGES \
LC_MONETARY \
LC_NAME \
LC_NUMERIC \
LC_PAPER \
LC_TELEPHONE \
LC_TIME
# Set every LC_* category implicitly with the `$LANG` fallback
export LANG=C.UTF-8