-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbootstrap.exclude.sh
executable file
·57 lines (46 loc) · 1.68 KB
/
bootstrap.exclude.sh
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
#!/bin/bash
set -e
# TODO IMPORTANT: when you bootstrap with sudo, ownership of certain files becomes root
# eg .vim/color, .vim/fzf, etc
. "$( pwd )/utils.exclude.sh"
PROMPT='[ Bootstrap ]'
source .exports
# Initialize a few things
init () {
echo_with_prompt "Making a Projects folder in $PATH_TO_PROJECTS if it doesn't already exist"
mkdir -p "$PATH_TO_PROJECTS"
echo_with_prompt "Making a Playground folder in $PATH_TO_PLAYGROUND if it doesn't already exist"
mkdir -p "$PATH_TO_PLAYGROUND"
echo_with_prompt "Making a Playground folder in $PATH_TO_JOURNAL if it doesn't already exist"
mkdir -p "$PATH_TO_JOURNAL"
}
# TODO : Delete symlinks to deleted files
# Is this where rsync shines?
# TODO - add support for -f and --force
link () {
for file in $( ls -A | grep -vE '\.exclude*|\.git$|\.gitignore|\.gitmodules|.*.md' ) ; do
# Silently ignore errors here because the files may already exist
if [ -f "$HOME/$file" -a ! -L "$HOME/$file" ]; then
echo_with_prompt "Backing up $HOME/$file as $HOME/$file.bak"
mv "$HOME/$file" "$HOME/$file.bak"
fi
ln -sv "$PWD/$file" "$HOME" || true
done
}
bootstrap_vim() {
# TODO consider sourcing this file
"$( pwd )/vim.bootstrap.exclude.sh"
}
bootstrap_crontab() {
# TODO consider sourcing this file
"$( pwd )/crontab.bootstrap.exclude.sh"
}
test-bins git curl
init
execute_func_with_prompt link "symlink everything"
execute_func_with_prompt bootstrap_vim "bootstrap vim with plugins and the like"
execute_func_with_prompt bootstrap_crontab "bootstrap the crontab"
# Hack to make sure this script always exits successfully
# Since the user may choose to cancel a step here and that is cool
# TODO rethink this system :p
true