diff options
| author | Vaino Kauppila <vaino@vke.fi> | 2026-09-10 14:42:46 +0300 |
|---|---|---|
| committer | Vaino Kauppila <vaino@vke.fi> | 2026-09-10 14:42:46 +0300 |
| commit | 02cf1cb1eb8e5611a30b8089228623493fbc771d (patch) | |
| tree | 861bc665f0488e82a8b9a77e74e15d748530e7ff /install.sh | |
| download | emacs_setup-02cf1cb1eb8e5611a30b8089228623493fbc771d.tar.gz emacs_setup-02cf1cb1eb8e5611a30b8089228623493fbc771d.zip | |
Import existing ~/.emacs as baseline, add tracking tooling
Byte-identical import of the live ~/.emacs (Emacs 31.1, loads clean
in batch and GUI apart from warnings noted in README).
Tooling: check.sh (batch-load validation), install.sh (backup +
symlink ~/.emacs -> emacs.el), Makefile, README.
Diffstat (limited to 'install.sh')
| -rwxr-xr-x | install.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..8a25c20 --- /dev/null +++ b/install.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# Deploy emacs.el from this repo as ~/.emacs. +# +# Uses a symlink instead of a copy, so ~/.emacs is ALWAYS the latest +# version in this repo -- no reinstall needed after pulls or commits. +# Bonus: edits made inside Emacs (e.g. M-x customize writing +# custom-set-variables) land in this repo's working tree and show up +# in `git diff`, ready to be committed. +set -euo pipefail + +REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SOURCE="$REPO_DIR/emacs.el" +TARGET="$HOME/.emacs" +BACKUP_DIR="$REPO_DIR/backups" + +if [ ! -f "$SOURCE" ]; then + echo "ERROR: $SOURCE not found" >&2 + exit 1 +fi + +# Already installed? +if [ "$(readlink "$TARGET" 2>/dev/null || true)" = "$SOURCE" ]; then + echo "~/.emacs already points at this repo. Nothing to do." + exit 0 +fi + +# Back up any existing config before replacing it +if [ -e "$TARGET" ] || [ -L "$TARGET" ]; then + mkdir -p "$BACKUP_DIR" + BACKUP="$BACKUP_DIR/emacs-$(date +%Y%m%d-%H%M%S)" + mv "$TARGET" "$BACKUP" + echo "Backed up existing config to $BACKUP" +fi + +ln -s "$SOURCE" "$TARGET" +echo "Installed: ~/.emacs -> $SOURCE" |
