all repos

dotfiles @ f09a3c7c0fdbbda341a9ef4c88c6bbb9d4d33cae

my dotfiles

bootstrap (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
set -euo pipefail

: "${DOTFILES_PATH:=$HOME/.dotfiles}"
: "${DOTFILES_HOME:=$HOME}"

lnk() {
  [[ -e "$2" ]] &&
    echo -e "\e[31m[ln] $1 (overwritten)\e[0m" ||
    echo -e "\r\e[32m[ln] $2\e[0m"
  ln -sf "$1" "$2"
}

dr() {
  mkdir -p "$1"
  echo -e "\e[34m[mkdir] $1\e[0m"
}

dotify() {
  local base_dir="$DOTFILES_PATH/$1"
  local target_dir="$2"

  find "$base_dir" -type d -print0 | while IFS= read -r -d '' dir; do
    dr "$DOTFILES_HOME/$target_dir${dir#"$base_dir"}"
    find "$dir" -maxdepth 1 -type f -print0 | while IFS= read -r -d '' file; do
      lnk "$file" "$DOTFILES_HOME/$target_dir${file#"$base_dir"}"
    done
  done
}

# let the lord do the linking
dotify "config" ".config"
dotify "bin" "bin"