forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·71 lines (62 loc) · 2.11 KB
/
bootstrap.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
git pull origin main;
function doIt() {
if [ ! -x "$(command -v brew)" ]; then
echo "Homebrew cannot be found, get it installed first"
if ! /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; then
echo "Homebrew cannot be installed"
exit 1
fi
fi
echo "Fetch all deps from Brewfile"
if ! brew bundle install; then
echo "Something went wrong in installing deps from Brewfile"
fi
if [ -x "$(command -v zsh)" ]; then
echo "We have zsh installed, and the following add-ons will be settled as well: on-my-zsh & powerlevel10k-theme"
# oh-my-zsh
if [ -x "$(command -v curl)" ]; then
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
elif [ -x "$(command -v wget)" ]; then
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
else
echo "Neither curl nor wget is available for fetching the source of oh-my-zsh"
fi
# Make sure zsh is in use
if [[ ! "$(SHELL)" = *zsh ]]; then
zsh
fi
# Powerlevel10k
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
# zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
fi
rsync --exclude ".git/" \
--exclude ".DS_Store" \
--exclude ".osx" \
--exclude ".macos" \
--exclude "bootstrap.sh" \
--exclude "init" \
--exclude "Brewfile" \
--exclude "README.md" \
--exclude "LICENSE-MIT.txt" \
-avh --no-perms . ~;
local shell_in_use="$(SHELL)"
if [[ $shell_in_use = *zsh ]]; then
source ~/.zshrc
elif [[ $shell_in_use = *bash ]]; then
source ~/.bash_profile;
fi
}
if [ "$1" == "--force" -o "$1" == "-f" ]; then
doIt;
else
read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1;
echo "";
if [[ $REPLY =~ ^[Yy]$ ]]; then
doIt;
fi;
fi;
unset doIt;