-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbootstrap.sh
118 lines (87 loc) · 2.74 KB
/
bootstrap.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
#!/bin/bash
GIT_NAME=${GIT_NAME:-"jonz94"}
GIT_MAIL=${GIT_MAIL:-"[email protected]"}
install() {
for INSTALL_SCRIPT in ~/dotfiles/scripts/install/*.sh; do
bash ${INSTALL_SCRIPT}
done
}
backup() {
if [ -f ${1} ]; then
mkdir -p $(dirname ${1})
TIMESTAMP=$(date +"%Y-%m-%d,%H:%M:%S")
echo "Backup old ${1} to ${1}.backup.${TIMESTAMP}"
mv ${1} ${1}.backup.${TIMESTAMP}
fi
}
setup_zsh() {
echo 'Setting up zsh...'
backup $HOME/.zshenv
backup $HOME/.zlogin
backup $HOME/.zimrc
ln -s $HOME/dotfiles/zsh/zim/zshenv.zsh $HOME/.zshenv
ln -s $HOME/dotfiles/zsh/zim/zlogin.zsh $HOME/.zlogin
ln -s $HOME/dotfiles/zsh/zim/zimrc.zsh $HOME/.zimrc
echo "source $HOME/dotfiles/zsh/zim/zshrc.zsh" > $HOME/.zshrc
# setup local configurations for zsh
mkdir -p ~/dotfiles/local
touch ~/dotfiles/local/local.zsh
touch ~/dotfiles/local/theme.zsh
echo 'Installing zsh modules...'
zsh ~/.zim/zimfw.zsh install
# disable Powerlevel10k configuration wizard
zsh -c "echo 'POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true' >>! ~/.zshrc"
echo 'zsh is ready!'
}
setup_neovim() {
echo 'Setting up neovim...'
NVIM_CONFIG_DIR="$HOME/.config/nvim"
# backup
if [ -e $NVIM_CONFIG_DIR ]; then
TIMESTAMP=$(date +"%Y-%m-%d,%H:%M:%S")
echo "Backup ${NVIM_CONFIG_DIR} to ${NVIM_CONFIG_DIR}.backup.${TIMESTAMP}"
mv ${NVIM_CONFIG_DIR} ${NVIM_CONFIG_DIR}.backup.${TIMESTAMP}
fi
mkdir -p $(dirname ${NVIM_CONFIG_DIR})
ln -s $HOME/dotfiles/nvim $NVIM_CONFIG_DIR
echo 'neovim is ready!'
}
setup_git() {
echo 'Setting up git...'
git config --global user.name ${GIT_NAME}
git config --global user.email ${GIT_MAIL}
git config --global pull.rebase true
git config --global core.editor nvim
git config --global init.defaultBranch main
echo 'git is ready!'
}
setup_tmux() {
echo 'Setting up tmux...'
backup ~/.tmux.conf
echo 'source-file $HOME/dotfiles/tmux/jonz94.tmux.conf' >> ~/.tmux.conf
# setup local configurations for tmux
mkdir -p ~/dotfiles/local
backup ~/dotfiles/local/theme.tmux.conf
cp ~/dotfiles/tmux/theme.tmux.conf ~/dotfiles/local/theme.tmux.conf
backup ~/dotfiles/local/themepack.tmux.conf
cp ~/dotfiles/tmux/themepack.tmux.conf ~/dotfiles/local/themepack.tmux.conf
echo 'Installing tmux plugins...'
~/.tmux/plugins/tpm/bin/install_plugins
echo 'tmux is ready!'
}
setup_fnm_completions_for_linux() {
if [ $(uname) = "Linux" ]; then
export PATH="$HOME/.local/share/fnm:$PATH"
eval "$(fnm env)"
rm -f ~/dotfiles/zsh/completions/_fnm
fnm completions --shell zsh > ~/dotfiles/zsh/completions/_fnm
fi
}
install
setup_zsh
setup_neovim
setup_git
setup_tmux
setup_fnm_completions_for_linux
echo '🎉 All Done!'
echo '🙌 Some changes might need re-login to take effects.'