-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·128 lines (111 loc) · 3.21 KB
/
install.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# exit immediately if a command exits with a non-zero status
set -e
while getopts ":e:" opt; do
case $opt in
e)
env=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG. Set the intended install environment with -e <environment>, where environment is \"work\" or \"personal\"." >&2
exit 1
;;
esac
done
if [ "$env" != "work" ] && [ "$env" != "personal" ]; then
echo "Invalid environment given. Valid environments are \"work\" and \"personal\"." >&2
exit 1
fi
set_up_homebrew() {
echo 'Installing homebrew...'
if which brew >/dev/null 2>&1; then
echo 'Homebrew already installed, skipping...'
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
}
set_up_rcm() {
echo 'Setting up RCM...'
if which rcup >/dev/null 2>&1; then
echo 'RCM already set up, skipping...'
else
mkdir -p $HOME/.dotfiles
cd $HOME/.dotfiles
brew install rcm # it's also in my brewfiles, but those aren't installed yet
rcdn
rcup -x README.md -x install.sh -x brewfiles -v
fi
}
install_main_bundle() {
echo 'Installing main brewfile...'
brew bundle --file $HOME/.dotfiles/brewfiles/main
}
set_up_private_dotfiles() {
echo 'Setting up private dotfiles...'
if [ -e "$HOME/.private/zshrc" ]; then
echo 'Private dotfiles already exist, skipping...'
else
mkdir -p $HOME/.private
touch $HOME/.private/zshrc
fi
}
set_up_zsh() {
echo 'Setting up ZSH...'
if which zsh >/dev/null 2>&1; then
echo 'ZSH already installed, skipping...'
else
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sudo chsh -s /usr/bin/zsh echo "$USER"
fi
}
# Taken from https://github.com/wassimk/dotfiles/blob/596a4b8573408fe96177f5e19f2142e6ef35c81d/dotfiles.sh#L25-L30
set_up_lazygit() {
echo "Setting up lazygit..."
real_lazygit_config_dir="$HOME/Library/Application Support/lazygit"
lazygit_config_file="$HOME/.config/lazygit/config.yml"
if [ -d "$real_lazygit_config_dir" ]; then
ln -sf "$lazygit_config_file" "$real_lazygit_config_dir/config.yml"
fi
}
install_zsh_theme() {
echo 'Installing ZSH theme (pure)...'
if [ -d "$HOME/Code/pure" ]; then
echo 'ZSH theme already installed, skipping...'
else
git clone https://github.com/sindresorhus/pure.git $HOME/Code/pure
fi
}
install_personal_bundle() {
echo 'Installing personal bundle...'
/opt/homebrew/bin/brew bundle --file $HOME/.dotfiles/brewfiles/personal
}
install_work_bundle() {
echo 'Installing work bundle...'
/opt/homebrew/bin/brew bundle --file $HOME/.dotfiles/brewfiles/work
}
set_up_dev_environment() {
echo 'Setting up dev environment...'
. $(brew --prefix asdf)/libexec/asdf.sh
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
asdf install
gem install bundler
npm install
}
set_up_homebrew
set_up_rcm
install_main_bundle
set_up_private_dotfiles
set_up_zsh
set_up_lazygit
install_zsh_theme
set_up_dev_environment
if [ "$env" == "personal" ]; then
install_personal_bundle
elif [ "$env" == "work" ]; then
install_work_bundle
fi
echo ''
echo 'Install complete! 🎉'
exit