feat: add install script

This commit is contained in:
Bradan J. Wolbeck 2026-06-16 23:43:37 -06:00
parent ff72fe0240
commit a5323d3226
2 changed files with 45 additions and 0 deletions

View file

@ -8,3 +8,10 @@ Clone:
```
git clone https://git.nanikore.de/compaqdisc/dotfiles.git ~/.dotfiles
```
Install:
```
~/.dotfiles/install.sh
```
The install script symlinks to the shared directory and backs up original files.

38
install.sh Executable file
View file

@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euo pipefail
DOTFILES="${DOTFILES:-$HOME/.dotfiles}"
link_file() {
local src="$1"
local dst="$2"
if [[ ! -e "$src" ]]; then
echo "missing source: $src"
return 1
fi
if [[ -L "$dst" && "$(readlink "$dst")" == "$src" ]]; then
echo "ok: $dst -> $src"
return 0
fi
if [[ -e "$dst" || -L "$dst" ]]; then
printf "replace %s? [y/N] " "$dst"
read -r answer
case "$answer" in
y|Y|yes|YES)
mv "$dst" "$dst.bak.$(date +%Y%m%d%H%M%S)"
;;
*)
echo "skip: $dst"
return 0
;;
esac
fi
mkdir -p "$(dirname "$dst")"
ln -s "$src" "$dst"
echo "linked: $dst -> $src"
}