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., `install-dotfiles` and `update-dotfiles`, and a `ensure-locales` helper) - Add README.md with info on the installation and general notes
This commit is contained in:
commit
e1cefdcd26
12 changed files with 424 additions and 0 deletions
87
.local/bin/dotfiles-update
Executable file
87
.local/bin/dotfiles-update
Executable file
|
|
@ -0,0 +1,87 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Replace the local `dotfiles` repository with a fresh install
|
||||
# by downloading and re-running the latest `dotfiles-install`
|
||||
#
|
||||
# Refuses to run if there are uncommitted or unpushed changes,
|
||||
# unless called with `--force`
|
||||
|
||||
set -eu
|
||||
|
||||
|
||||
XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" # also set in ~/.config/shell/env
|
||||
DOTFILES_DIR="$XDG_DATA_HOME/dotfiles" # also set in ~/.config/shell/env
|
||||
|
||||
|
||||
if [ -d "$DOTFILES_DIR" ]; then
|
||||
|
||||
_git() {
|
||||
git --git-dir="$DOTFILES_DIR" --work-tree="$HOME" "$@"
|
||||
}
|
||||
|
||||
# Keep the machine on its current branch (e.g., "desktop")
|
||||
branch=$(_git symbolic-ref --short HEAD) || {
|
||||
echo "" >&2
|
||||
echo "Detached HEAD => re-run after 'dotfiles checkout <branch>'" >&2
|
||||
echo "" >&2
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ "${1:-}" = "--force" ] && force=1 || force=0
|
||||
|
||||
if [ "$force" -ne 1 ]; then
|
||||
|
||||
if [ -n "$(_git status --porcelain)" ]; then
|
||||
echo "" >&2
|
||||
echo "There are uncommitted changes!" >&2
|
||||
echo "" >&2
|
||||
_git --no-pager diff HEAD --stat >&2
|
||||
echo "" >&2
|
||||
echo "=> Commit and push them, or re-run with --force" >&2
|
||||
echo "" >&2
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if _git rev-parse --verify --quiet "origin/$branch" >/dev/null \
|
||||
&& [ -n "$(_git log --oneline "origin/$branch..$branch")" ]; then
|
||||
echo "" >&2
|
||||
echo "There are unpushed commits!" >&2
|
||||
echo "" >&2
|
||||
_git --no-pager log --oneline "origin/$branch..$branch" >&2
|
||||
echo "" >&2
|
||||
echo "=> Push them, or re-run with --force" >&2
|
||||
echo "" >&2
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
else
|
||||
branch="main"
|
||||
fi
|
||||
|
||||
|
||||
installer_url="https://code.webartifex.de/alexander/dotfiles/raw/branch/$branch/.local/bin/dotfiles-install"
|
||||
|
||||
installer_path=$(mktemp)
|
||||
trap 'rm -f "$installer_path"' EXIT
|
||||
|
||||
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
curl -fsSL "$installer_url" -o "$installer_path"
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
wget -q "$installer_url" -O "$installer_path"
|
||||
else
|
||||
echo "" >&2
|
||||
echo "Neither curl nor wget are installed!" >&2
|
||||
echo "=> Install one of them" >&2
|
||||
echo "" >&2
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
sh "$installer_path" --force
|
||||
Loading…
Reference in a new issue