-
Notifications
You must be signed in to change notification settings - Fork 1
/
installer.sh
166 lines (131 loc) · 4.43 KB
/
installer.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
#!/bin/bash
timestamp=$(date +%Y%m%d%H%M%S)
echo $timestamp
beforeInstall() {
if [ -f ~/.gitconfig ]; then
echo "$HOME/.gitconfig exists"
mv ~/.gitconfig ~/.gitconfig_$timestamp
fi
if [ -f ~/.zshrc ]; then
echo "$HOME/.zshrc exists"
mv ~/.zshrc ~/.zshrc_$timestamp
fi
if [ -d ~/.oh-my-zsh ]; then
echo "$HOME/.oh-my-zsh exists"
mv -f ~/.oh-my-zsh ~/.oh-my-zsh_$timestamp
fi
if [ -d ~/.config/nvim ]; then
echo "$HOME/.config/nvim exists"
mv -f ~/.config/nvim ~/.config/nvim_$timestamp
fi
mkdir -p ~/.config/
}
SoftLinks() {
cp ~/.dotfiles/config/gitconfig ~/.gitconfig
cp ~/.dotfiles/config/gitignore ~/.gitignore
if [ ! -f ~/.ssh/id_rsa ]; then
ssh-keygen -q -t rsa -b 4096 -C "" -f ~/.ssh/id_rsa -N ""
else
echo "SSH key pair already exists."
fi
mkdir -p ~/.config/pip
cp ~/.dotfiles/config/pip.conf ~/.config/pip/pip.conf
}
InstallOhMyZsh() {
# ln -s ~/.dotfiles/zsh/zshrc ~/.zshrc
cp ~/.dotfiles/zsh/zshrc ~/.zshrc
echo ": 1700000000:0;ps aux | grep ssh" >>~/.zsh_history
git clone --single-branch --depth 1 https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
if [[ $SHELL == *"zsh"* ]]; then
echo "shell is zsh now"
else
chsh -s $(which zsh)
fi
git clone --single-branch --depth 1 https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions
git clone --single-branch --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
ln -s ~/.dotfiles/zsh/Schminitz.zsh-theme ~/.oh-my-zsh/custom/themes/Schminitz.zsh-theme
}
InstallNeovim() {
ln -s ~/.dotfiles/nvim ~/.config/nvim
ln -s ~/.dotfiles/config/pycodestyle ~/.config/pycodestyle
# install python env
python3 -m venv ~/.venv/py3
~/.venv/py3/bin/pip install better_exceptions neovim black ruff
}
Installasdf() {
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.1
. $HOME/.asdf/asdf.sh
# install nodejs
asdf plugin add nodejs
# asdf list all nodejs
asdf install nodejs 20.17.1
asdf global nodejs 20.17.1
# asdf plugin add neovim
# asdf list all neovim
# asdf install neovim latest
# asdf global neovim latest
}
InstallOthers() {
# Mac OS X 操作系统
if [[ $(uname) == 'Darwin' ]]; then
echo "mac"
brew install alacritty tmux fzf zoxide lua
# 安装鼠须管
brew install --cask squirrel
# 参考配置
git clone --single-branch --depth=1 https://github.com/iDvel/rime-ice ~/Library/Rime
ln -s ~/.dotfiles/config/rime/*.yaml ~/Library/Rime
# 重新部署
# /Library/Input\ Methods/Squirrel.app/Contents/MacOS/Squirrel --reload
# GNU/Linux操作系统
# 需要重启
elif [[ $(uname) == 'Linux' ]]; then
echo "Linux"
# download chsrc
mkdir bin
curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-x64-linux -o bin/chsrc
chmod +x ./bin/chsrc
pacman --noconfirm -Syy
# Windows NT操作系统
else
echo "Nonsupport system"
fi
# 配置alacritty
mkdir -p ~/.config/alacritty/
ln -s ~/.dotfiles/config/alacritty.toml ~/.config/alacritty
# 配置tmux
ln -s ~/.dotfiles/config/tmux.conf ~/.tmux.conf
# mkdir -p ~/.config/tmux/
# ln -s ~/.dotfiles/config/tmux.conf ~/.config/tmux/tmux.conf
mkdir -p ~/.tmux/plugins
git clone --single-branch --depth=1 https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
git clone --single-branch --depth=1 https://github.com/hjkl01/catppuccin_tmux ~/.tmux/plugins/catppuccin_tmux
git clone --single-branch --depth=1 https://github.com/tmux-plugins/tmux-cpu ~/.tmux/plugins/tmux-cpu
# 配置zellij
# zellij setup --dump-config > ~/.config/zellij/config.kdl
# mkdir -p ~/.config/zellij/
# ln -s ~/.dotfiles/config/zellij.kdl ~/.config/zellij/config.kdl
# ln -s ~/.dotfiles/config/layouts ~/.config/zellij/layouts
}
# echo $@
# 定义一个函数,用于执行其他函数并捕获错误
execute_function() {
local func_name=$1
shift
# 尝试执行函数
if ! "$func_name" "$@"; then
# 如果函数执行失败,输出错误信息并继续执行
echo "Error executing function: $func_name"
fi
}
execute_function beforeInstall
if [ "$1" = "link" ]; then
echo "link in args, run soft link"
SoftLinks
fi
execute_function InstallOhMyZsh
execute_function InstallNeovim
execute_function Installasdf
execute_function InstallOthers
echo "edit ~/.oh-my-zsh/themes/Schminitz.zsh-themes to update themes"
echo "finish ! logout and relogin"