-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup_mac
executable file
·189 lines (147 loc) · 3.87 KB
/
setup_mac
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
#!/usr/bin/env bash
## PRECONDITIONS
# 1)
# Enable App Management permissions for Terminal
# (System Settings -> Privacy & Security)
#
# 2)
# https://docs.brew.sh/Installation#macos-requirements
# xcode-select --install
set -e
fancy_echo() {
local fmt="$1"; shift
printf "\\n$fmt\\n" "$@"
}
ask_for_sudo() {
# Ask for the administrator password upfront.
sudo -v &> /dev/null
# Update existing `sudo` time stamp
# until this script has finished.
#
# https://gist.github.com/cowboy/3118588
# Keep-alive: update existing `sudo` time stamp until script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
}
# cache sudo password
fancy_echo "Caching sudo password..."
ask_for_sudo
## Homebrew
#
# install homebrew
if test ! $(which brew); then
fancy_echo "Installing homebrew..."
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# add Homebrew to path
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
brew update
brew upgrade
PACKAGES=(
htop
diff-so-fancy
ncdu
exiftool
git
zsh
zsh-completions
curl
n
neovim
ripgrep
fd
stow
fzf
go
gopls
ansible
tmux
bettertouchtool
wget
jq
zsh-autosuggestions
pure
)
fancy_echo "Installing packages..."
brew install ${PACKAGES[@]}
APPS=(
alfred
firefox
visual-studio-code
imageoptim
spotify
docker
font-fira-code
obsidian
insomnia
alacritty
gimp
# optional:
#
# veracrypt
# libreoffice
# nextcloud
# discord
)
fancy_echo "Installing apps..."
brew install --cask ${APPS[@]}
fancy_echo "Cleaning up Homebrew stuff..."
brew cleanup
## Tmux and Alacritty settings and dependencies
#
# install tmux plugin manager
if [ ! -d $HOME/.tmux/plugins/tpm ]; then
fancy_echo "Installing Tmux Plugin Manager..."
git clone https://github.com/tmux-plugins/tpm $HOME/.tmux/plugins/tpm
fi
# install catppuccin macchiato alacritty theme
if [ ! -f $HOME/.config/alacritty/catppuccin-macchiato.toml ]; then
fancy_echo "Installing Alacritty Catppuccin theme..."
curl -LO --output-dir ~/.config/alacritty https://github.com/catppuccin/alacritty/raw/main/catppuccin-macchiato.toml
fi
## Misc
#
# install npm completions
npm completion > /opt/homebrew/share/zsh/site-functions/npm
# install Node LTS
fancy_echo "Installing Node LTS..."
N_PREFIX="$HOME/.n" n lts
fancy_echo "Installing PNPM..."
npm install -g pnpm
# create folder
mkdir -p $HOME/code
mkdir -p $HOME/Notes
# copy git config
cp ./git/.gitconfig ~/.gitconfig
# symlink files
./install
## MacOS settings
#
# disabling press-and-hold for keys in favor of a key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
# lower key repeat delay
# normal minimum is 15 (225ms)
defaults write NSGlobalDomain InitialKeyRepeat -int 12
# normal minimum is 2 (30 ms)
defaults write NSGlobalDomain KeyRepeat -int 2
# change screenshot location to ~/Screenshots
mkdir -p ~/Screenshots && defaults write com.apple.screencapture location ~/Screenshots
# don’t automatically rearrange Spaces based on most recent use
defaults write com.apple.dock mru-spaces -bool false
# showing all filename extensions in Finder by default
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# disabling the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# expand save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
# avoid creating .DS_Store files on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
killall SystemUIServer
cd $WORKSPACE
printf "
All done!
"
## Finish
#
# reload shell to apply changes
exec ${SHELL} -l