-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·61 lines (50 loc) · 1.4 KB
/
bootstrap.sh
File metadata and controls
executable file
·61 lines (50 loc) · 1.4 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# avoid re-typing common arguments to rsync
function run_sync() {
rsync \
-ah \
--no-perms \
--exclude ".DS_Store" \
$@
}
# sync platform agnostic dotfiles
function copy_common() {
echo ""; echo "Copying dotfiles"
run_sync --exclude "platform_specific/" "$dir_in/" $dir_out
echo "Dotfiles sync complete"
}
# sync mac-specific files
function copy_mac() {
echo ""; echo "Detected macOS, Copying .macos init file to ~."
echo "Execute it manually to set preferred macOS options."
run_sync "$dir_in/platform_specific/mac/" $dir_out
echo "macOS files sync complete"
}
# sync linux-specific files
function copy_linux() {
echo ""; echo "Detected linux, Copying linux specific files to ~."
run_sync "$dir_in/platform_specific/linux/" $dir_out
echo "Linux files sync complete"
}
# run
function begin() {
read -p "This script may overwrite files. Continue? (y/n) " -n 1; echo ""
# exit early if user says no
if [[ $REPLY =~ ^[nN]$ ]]; then
echo "Aborting"
return
fi
dir_in="./home_files"
dir_out="$HOME/"
platform=$(uname -s)
# sync platform agnostic dotfiles
copy_common
# sync platform-specific files
if [[ $platform == "Darwin" ]]; then
copy_mac
elif [[ $platform == "Linux" ]]; then
copy_linux
fi
echo ""; echo "============= Done ============="
}
begin