-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_mac.sh
213 lines (183 loc) · 5.45 KB
/
setup_mac.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/bin/bash
DOTFILESDIR=$(dirname "$0")
function main() {
install_brew
install_firefox
install_kitty
install_node
install_golang
install_neovim
install_tmux
install_oh_my_zsh
set_keyboard_preferences
set_trackpad_preferences
set_mouse_preferences
set_clock_preferences
install_bash_aliases
install_zshrc_config
install_git_config
install_tmux_config
install_fzf
install_sdkman && install_java
}
function install_brew() {
if ! command -v brew &> /dev/null
then
echo "Installing brew"
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
echo "brew already exists, skipping install."
fi
}
function install_firefox() {
if ! brew list firefox &> /dev/null
then
echo "Installing Firefox"
brew install --cask firefox
else
echo "firefox already exists, skipping install."
fi
}
function install_kitty() {
if ! command -v kitty &> /dev/null
then
echo "Installing kitty"
curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin
mkdir -p ~/.config/kitty/
cp $DOTFILESDIR/.config/kitty/kitty.conf ~/.config/kitty/kitty.conf
else
echo "kitty already exists, skipping install."
fi
}
function install_neovim() {
if ! command -v nvim &> /dev/null
then
echo "Installing neovim."
brew install neovim
else
echo "neovim already exists, skipping install."
fi
echo "Installing neovim config."
mkdir -p "$HOME/.config/nvim/"
_backup_file "$HOME/.config/nvim/init.vim"
cp $DOTFILESDIR/.config/nvim/init.vim $HOME/.config/nvim/init.vim
if [ -f "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim ]
then
echo "Vim-plug already exists, skipping install"
else
echo "Installing vim-plug."
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
fi
nvim -c ":PlugClean" -c ":PlugInstall"
nvim -c ":LspInstall gopls" -c ":LspInstall bashls" -c ":LspInstall jdtls"
}
function install_golang() {
if ! command -v go &> /dev/null
then
echo "Installing golang"
brew install go
else
echo "golang already exists, skipping install."
fi
}
function install_tmux() {
if ! command -v tmux &> /dev/null
then
echo "Installing tmux"
brew install tmux
else
echo "tmux already exists, skipping install."
fi
}
function install_oh_my_zsh() {
if [ -d "$HOME/.oh-my-zsh" ]; then
echo "oh-my-zsh already exists, skipping install."
else
echo "Installing oh-my-zsh."
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
}
function set_clock_preferences() {
echo "Setting Mac clock preferences"
defaults write com.apple.menuextra.clock DateFormat -string "EEE MMM d j:mm:ss a"
}
function set_trackpad_preferences() {
echo "Setting Mac trackpad preferences."
# tap-to-click enabled
defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
}
function set_mouse_preferences() {
echo "Setting Mac mouse preferences."
# increase mouse sensitivity
defaults write -g com.apple.mouse.scaling -int 2
}
function set_keyboard_preferences() {
echo "Setting Mac keyboard preferences."
defaults write -g InitialKeyRepeat -int 10 # normal minimum is 15 (225 ms)
defaults write -g KeyRepeat -int 1 # normal minimum is 2 (30 ms)
}
function install_bash_aliases() {
echo "Installing bash aliases."
_backup_file "$HOME/.bash_aliases"
cp $DOTFILESDIR/.bash_aliases $HOME/.bash_aliases
}
function install_zshrc_config() {
echo "Installing zshrc."
_backup_file "$HOME/.zshrc"
cp $DOTFILESDIR/.zshrc $HOME/.zshrc
zsh "$HOME/.zshrc"
}
function install_git_config() {
if [ -f "$HOME/.gitconfig" ]; then
echo "git config already exists, skipping."
else
echo "Instaling git config."
cp $DOTFILESDIR/.gitconfig $HOME/.gitconfig
fi
}
function install_tmux_config() {
echo "Instaling tmux config."
_backup_file "$HOME/.tmux.conf"
cp $DOTFILESDIR/.tmux.conf $HOME/.tmux.conf
}
function install_fzf() {
echo "Instaling fzf."
if ! command -v fzf &> /dev/null
then
echo "Installing fzf"
brew install fzf
$(brew --prefix)/opt/fzf/install --all --key-bindings --completion --update-rc
else
echo "fzf already exists, skipping install."
fi
}
function install_node() {
if ! command -v node &> /dev/null
then
echo "Installing node"
brew install node
else
echo "node already exists, skipping install."
fi
}
function _backup_file() {
local source_file=$1
if [ -f "$source_file" ]; then
local fname="$source_file.bak.$(date -u +%s)"
echo "$source_file already exists, backing up to $fname."
cp $source_file $fname
fi
}
function install_sdkman() {
curl -s "https://get.sdkman.io" | bash
source ~/.zshrc
}
function install_java() {
sdk install java 17.0.5-zulu
sdk install gradle
sdk install maven
}
main