#!/bin/bash
set -euo pipefail
cd -- "$(dirname -- "$0")"

function main() {
  local home
  local dotfile
  home=$(eval echo ~"${SUDO_USER:-$(id -un)}")
  for dotfile in .*; do
    [[ $dotfile =~ ^(\.\.?|\.git)$ ]] && continue

    dotfile=$(realpath "$dotfile")
    (
      cd -- "$home"
      ln -svf "$dotfile" .
    )
  done
}

main