all repos

dotfiles @ 6c88a61d8c62f2e16fb61e8999ef611f3024226a

i use rach linux btw

dotfiles/bootstrap (view raw)

1
#!/usr/bin/env bash
2
set -euo pipefail
3
4
: "${DOTFILES_PATH:=$HOME/.dotfiles}"
5
: "${DOTFILES_HOME:=$HOME}"
6
7
lnk() {
8
  [[ -e "$2" ]] &&
9
    echo -e "\e[31m[ln] $1 (overwritten)\e[0m" ||
10
    echo -e "\r\e[32m[ln] $2\e[0m"
11
  ln -sf "$1" "$2"
12
}
13
14
dr() {
15
  mkdir -p "$1"
16
  echo -e "\e[34m[mkdir] $1\e[0m"
17
}
18
19
dotify() {
20
  local base_dir="$DOTFILES_PATH/$1"
21
  local target_dir="$2"
22
23
  find "$base_dir" -type d -print0 | while IFS= read -r -d '' dir; do
24
    dr "$DOTFILES_HOME/$target_dir${dir#"$base_dir"}"
25
    find "$dir" -maxdepth 1 -type f -print0 | while IFS= read -r -d '' file; do
26
      lnk "$file" "$DOTFILES_HOME/$target_dir${file#"$base_dir"}"
27
    done
28
  done
29
}
30
31
# let the lord do the linking
32
dotify "config" ".config"
33
dotify "bin" "bin"