-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap
More file actions
executable file
·47 lines (38 loc) · 1.32 KB
/
bootstrap
File metadata and controls
executable file
·47 lines (38 loc) · 1.32 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -e
repo="https://git.atomaka.com/atomaka/dotfiles.git"
local_dir="$HOME/.local/bin"
chezmoi_source_dir="$HOME/.local/share/chezmoi"
home_brew_paths="/opt/homebrew/bin:/home/linuxbrew/.linuxbrew/bin"
PATH="$local_dir:$home_brew_paths:$PATH"
echo "==> Bootstrapping dotfiles..."
if [[ "$(uname)" == "Darwin" ]] && [[ ! -e "/Library/Developer/CommandLineTools/usr/bin/git" ]]; then
echo -n "Installing Xcode Command Line Tools..."
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
tools="$(/usr/sbin/softwareupdate -l |
grep -B 1 -E 'Command Line Tools' |
awk -F'*' '/^ *\*/ {print $2}' |
sed -e 's/^ *Label: //' -e 's/^ *//' |
sort -V |
tail -n1)"
if [[ -n "${tools}" ]]; then
sudo /usr/sbin/softwareupdate -i "${tools}"
fi
rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
echo "done"
fi
if ! command -v chezmoi &> /dev/null; then
echo -n "Installing chezmoi..."
sh -c "$(curl -fsSL https://git.io/chezmoi)" -- -b "$local_dir"
echo "done"
fi
if [ ! -d "$chezmoi_source_dir" ]; then
echo -n "Initializing chezmoi with dotfiles repository..."
chezmoi init --apply "$repo"
echo "done"
fi
if [ -f "$local_bin/chezmoi" ]; then
rm -f "$local_bin/chezmoi"
fi
echo ""
echo "==> Bootstrap complete!"