-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·182 lines (160 loc) · 5.12 KB
/
setup.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
#!/bin/bash
# output all the commands running
set -eux
# Install util apps:
# 1. Mos - makes non-apple mouses to work more smooth
if ! brew list mos &> /dev/null; then
brew install --cask mos
# configure launch at login
cat <<EOT >> ~/Library/LaunchAgents/Mos.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>RunAtLoad</key>
<true />
<key>KeepAlive</key>
<false />
<key>Label</key>
<string>Mos</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Mos.app/Contents/MacOS/Mos</string>
</array>
</dict>
</plist>
EOT
launchctl load ~/Library/LaunchAgents/Mos.plist
fi
# 2. Maccy - clipboard buffer
if ! brew list maccy &> /dev/null; then
brew install --cask maccy
# configure launch at login
cat <<EOT >> ~/Library/LaunchAgents/Maccy.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>RunAtLoad</key>
<true />
<key>KeepAlive</key>
<false />
<key>Label</key>
<string>Maccy</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Maccy.app/Contents/MacOS/Maccy</string>
</array>
</dict>
</plist>
EOT
launchctl load ~/Library/LaunchAgents/Maccy.plist
fi
# 3. App-Cleaner - cleaner way to delete apps
if ! brew list app-cleaner &> /dev/null; then
brew install --cask app-cleaner
fi
# 4. Karabiner-Elements - keyboard remapper
if ! brew list karabiner-elements &> /dev/null; then
brew install --cask karabiner-elements
# configure launch at login
cat <<EOT >> ~/Library/LaunchAgents/Karabiner-Elements.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>RunAtLoad</key>
<true />
<key>KeepAlive</key>
<false />
<key>Label</key>
<string>Karabiner-Elements</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Karabiner-Elements.app/Contents/MacOS/Karabiner-Elements</string>
</array>
</dict>
</plist>
EOT
launchctl load ~/Library/LaunchAgents/Karabiner-Elements.plist
fi
# 5. MonitorControl - adjust external monitor brightness from keyboard
if ! brew list monitorcontrol &> /dev/null; then
brew install --cask monitorcontrol
# configure launch at login
# due to random crashes need to restart automatically, so KeepAlive=true (solution from here: https://github.com/MonitorControl/MonitorControl/issues/902#issuecomment-1026924937)
cat <<EOT >> ~/Library/LaunchAgents/MonitorControl.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>RunAtLoad</key>
<true />
<key>KeepAlive</key>
<true />
<key>Label</key>
<string>MonitorControl</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/MonitorControl.app/Contents/MacOS/MonitorControl</string>
</array>
</dict>
</plist>
EOT
launchctl load ~/Library/LaunchAgents/MonitorControl.plist
fi
# 6. Rectangle - window manager
if ! brew list rectangle &> /dev/null; then
brew install --cask rectangle
# configure launch at login
cat <<EOT >> ~/Library/LaunchAgents/Rectangle.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>RunAtLoad</key>
<true />
<key>KeepAlive</key>
<false />
<key>Label</key>
<string>Rectangle</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Rectangle.app/Contents/MacOS/Rectangle</string>
</array>
</dict>
</plist>
EOT
launchctl load ~/Library/LaunchAgents/Rectangle.plist
fi
# Link config files:
# 1. Karabiner
mkdir -p ~/.config/karabiner
[ -f ~/.config/karabiner/karabiner.json ] && cp ~/.config/karabiner/karabiner.json ~/.config/karabiner/karabiner.json.$(date +"%Y-%m-%d_%H-%M-%S").back
ln -sf $(pwd)/karabiner.json ~/.config/karabiner/karabiner.json
# 2. Rectangle
mkdir -p ~/Library/Application\ Support/Rectangle
ln -sf $(pwd)/RectangleConfig.json ~/Library/Application\ Support/Rectangle/RectangleConfig.json
# Link scripts:
[ -d ~/scripts ] && cp -R ~/scripts ~/scripts.$(date +"%Y-%m-%d_%H-%M-%S").back
ln -sf $(pwd)/scripts/* ~/scripts
# Git aliases
git config --global alias.cb "rev-parse --abbrev-ref HEAD" # current branch
git config --global alias.st "status"
git config --global alias.nb "checkout -b" # new branch
git config --global alias.back "checkout -"
git config --global alias.ch "checkout"
# Create global .gitignore
cat <<EOT > ~/.config/git/ignore
.gitignored
.DS_Store
.idea
.vscode
EOT
# Cache git credentials in Keychain app
git config --global credential.helper osxkeychain
# Useful CLI utils
pip3 install shell-gpt
# Show Cmd+Tab pane on all displays
defaults write com.apple.dock appswitcher-all-displays -bool true
killall Dock