-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathup.sh
executable file
·230 lines (181 loc) · 7 KB
/
up.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/bash
# set -x
set -euo pipefail
choice_install_apps="skip_by_default"
choice_install_fonts="skip_by_default"
choice_update_mac_defaults="skip_by_default"
while getopts ":a:f:m:" opt; do
case $opt in
a) choice_install_apps="$OPTARG"
;;
f) choice_install_fonts="$OPTARG"
;;
m) choice_update_mac_defaults="$OPTARG"
;;
\?) echo "Invalid option -$OPTARG" >&2
exit 1
;;
esac
done
######################################################
## clone dotfiles
if [ ! -d ~/.dotfiles ]; then
echo "#### pull .dotfiles"
(cd && GIT_SSH_COMMAND='ssh -i ~/.ssh/id_rsa_personal -o IdentitiesOnly=yes' git clone git@github.com:404pilot/.dotfiles.git)
fi
######################################################
## install necessary apps
apps=(git ccat vim zsh antigen autojump tmux blueutil sleepwatcher direnv nvm)
if [[ "$choice_install_apps" == "install_apps" ]]; then
for app in "${apps[@]}"
do
echo "#### install $app"
brew list $app || brew install $app
done
fi
######################################################
## install fonts
if [[ "$choice_install_fonts" == "install_fonts" ]]; then
brew tap homebrew/cask-fonts || true && brew install --cask font-fira-code-nerd-font
fi
######################################################
## iterm2
echo "### Config iterm2"
# Specify the preferences directory
defaults write com.googlecode.iterm2 PrefsCustomFolder -string "~/.dotfiles/iterm2"
# Tell iTerm2 to use the custom preferences in the directory
defaults write com.googlecode.iterm2 LoadPrefsFromCustomFolder -bool true
######################################################
## bash & bash_completion & jenv & rbenv
# echo "#### Config bash and other configs (bash_completion, jenv, rbenv)"
# cp ~/.dotfiles/bash/bash_profile ~/.bash_profile
# rm ~/.bashrc
# echo "source ~/.dotfiles/bash/bash_bridge" > ~/.bashrc
# echo "source ~/.dotfiles/bash/bash_other_app_configs" >> ~/.bashrc
######################################################
## zsh & jenv & sdkman
echo "#### Config zsh and other configs (bash_completion, jenv, sdkman ...)"
rm ~/.zshrc || true \
&& ln -s ~/.dotfiles/zsh/zshrc ~/.zshrc
######################################################
## vim
echo "#### Config vim"
rm ~/.vimrc || true \
&& ln -s ~/.dotfiles/vim/vimrc ~/.vimrc \
&& curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
######################################################
## ideavim
echo "#### Config ideavim"
rm ~/.ideavimrc || true \
&& ln -s ~/.dotfiles/ideavim/ideavimrc ~/.ideavimrc
######################################################
## editorConfig
echo "#### Config editorConfig"
rm ~/.editorconfig || true \
&& ln -s ~/.dotfiles/editorConfig/editorconfig ~/.editorconfig
######################################################
## tmux
echo "#### Config tmux"
rm ~/.tmux.conf || true \
&& ln -s ~/.dotfiles/tmux/tmux.conf ~/.tmux.conf
# make sure terminal: $TERM=xterm-256color
export TERM=xterm-256color
if [ ! -d ~/.tmux/plugins/tpm ]; then
echo "git clone tpm plugins..."
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
echo "installing plugins..."
~/.tmux/plugins/tpm/bin/install_plugins
fi
######################################################
## ssh
echo "#### Config ssh"
rm ~/.ssh/config || true \
&& ln -s ~/.dotfiles/ssh/config ~/.ssh/config
######################################################
## Karabiner
##
## by default, click 'Open config folder' from karabiner will delete the symbolink file and generate the latest configuration json file
## which it is a way to configure stuff in GUI first and then get the corresponding configuration file
##
## Tips: find the bundle id by using the osascript "osascript -e 'id of app "Microsoft Remote Desktop"'"
## or `mdls -name kMDItemCFBundleIdentifier /Applications/Microsoft\ Remote\ Desktop\ Beta.app`
echo "#### Config karabiner"
rm ~/.config/karabiner/karabiner.json || true \
&& ln -s ~/.dotfiles/karabiner/karabiner.json ~/.config/karabiner/karabiner.json
# rm ~/Library/Application\ Support/Karabiner/private.xml || true \
# && ln -s ~/.dotfiles/karabiner/private.xml ~/Library/Application\ Support/Karabiner/private.xml
######################################################
## hammerspoon
echo "#### Config hammerspoon"
rm ~/.hammerspoon/init.lua || mkdir ~/.hammerspoon || true \
&& ln -s ~/.dotfiles/hammerspoon/init.lua ~/.hammerspoon/init.lua
######################################################
## shuttle
echo "#### Config shuttle"
rm ~/.shuttle.json || true \
&& ln -s ~/.dotfiles/shuttle/shuttle.json ~/.shuttle.json
######################################################
## poetry
# echo "#### Config poetry"
#
# POETRY_CONFIG_PATH="${HOME}/Library/Application Support/pypoetry"
#
# if [ -d "${POETRY_CONFIG_PATH}" ]; then
# rm "${POETRY_CONFIG_PATH}/config.toml" || true \
# && ln -s ~/.dotfiles/poetry/config.toml "${POETRY_CONFIG_PATH}/config.toml"
# fi
######################################################
## git
echo "#### Config git"
rm ~/.gitconfig || true \
&& ln -s ~/.dotfiles/git/gitconfig ~/.gitconfig
function set_up_git_config_for_work(){
local location=$1
mkdir -p $location
if [ ! -f $location/gitconfig-work ]; then
echo "######## Please modify $location/gitconfig-work"
cp ~/.dotfiles/git/gitconfig-work $location
fi
}
set_up_git_config_for_work ~/Work/private
set_up_git_config_for_work ~/Work/public
set_up_git_config_for_work ~/Work/ms
######################################################
## sleepwatcher
echo "#### Config sleepwatcher"
rm ~/.sleep || true \
&& ln -s ~/.dotfiles/sleepwatcher/sleep ~/.sleep
rm ~/.wakeup || true \
&& ln -s ~/.dotfiles/sleepwatcher/wakeup ~/.wakeup
brew services restart sleepwatcher
######################################################
## macOS
# see docs at https://macos-defaults.com/
# defaults reads
# defaults domains
# lots of configurations exist at ~/Library/Preferences
echo "#### Config macOS defaults values"
if [[ "$choice_update_mac_defaults" == "update_mac_defaults" ]]; then
# backup current settings
defaults read > /tmp/defaults_read_$(date -u +"%Y-%m-%dT%H:%M:%SZ").bak
# save screenshots to ~/Documents
defaults write com.apple.screencapture location $HOME/documents && killall SystemUIServer
# allow repeated keys
defaults write -g ApplePressAndHoldEnabled -bool false
# show all extensions name
defaults write NSGlobalDomain "AppleShowAllExtensions" -bool "true" && killall Finder
# show path
defaults write com.apple.finder "ShowPathbar" -bool true && killall Finder
# set dock position
defaults write com.apple.dock "orientation" -string "left" \
&& defaults write com.apple.dock "show-recents" -bool "false" \
&& killall Dock
# set default view in finder
defaults write com.apple.finder "FXPreferredGroupBy" -string "Kind" \
&& defaults write com.apple.finder "FXPreferredViewStyle" -string "Nlsv" \
&& killall Finder
fi
######################################################
## done
echo "#### Finish"