-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·74 lines (59 loc) · 1.75 KB
/
install.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
#!/usr/bin/env bash
set -euo pipefail
PWD=$(pwd)
INSTALL_DIR="$HOME/.oh-my-zsh"
CONFIG_FILES=(
".zshrc.local"
".tmux.conf"
".zsh_plugins"
".zsh_aliases"
".config/aria2"
".config/k9s"
".config/nano"
".config/regolith2"
".config/youtube-dl"
".config/user-dirs.dirs"
)
LOCAL_BIN_PATH="$HOME/.local/bin"
git submodule init
git submodule update
if [[ -d "$INSTALL_DIR" ]]; then
mv "$INSTALL_DIR" "$INSTALL_DIR.bak"
fi
for fileName in "${CONFIG_FILES[@]}"; do
if [[ -r "$HOME/$fileName" ]]; then
mv "$HOME/$fileName" "$HOME/$fileName.bak"
fi
done
git clone https://github.com/robbyrussell/oh-my-zsh.git "$HOME/.oh-my-zsh"
if [[ -e "$HOME/.zshrc" ]]; then
mv "$HOME/.zshrc" "$HOME/.zshrc.bak"
fi
for PLUGIN_PATH in "$PWD"/custom/plugins/*; do
PLUGIN_NAME="$(basename "$PLUGIN_PATH")"
ln -sf "$PLUGIN_PATH" "$INSTALL_DIR/custom/plugins/$PLUGIN_NAME"
done
for THEME_PATH in "$PWD"/custom/themes/*; do
THEME_NAME="$(basename "$THEME_PATH")"
ln -sf "$THEME_PATH" "$INSTALL_DIR/custom/themes/$THEME_NAME"
done
mkdir -p "$LOCAL_BIN_PATH"
for BINARY_PATH in "$PWD"/bin/*; do
BINARY_NAME="$(basename "$BINARY_PATH")"
ln -sf "$BINARY_PATH" "$LOCAL_BIN_PATH/$BINARY_NAME"
done
for fileName in "${CONFIG_FILES[@]}"; do
LINK="$HOME/$fileName"
mkdir -p $(dirname "$LINK")
ln -sf "$PWD/$fileName" "$LINK"
if [[ -r "$HOME/$fileName.bak" ]]; then
echo ""
echo "$HOME/$fileName.bak >>>> $HOME/$fileName"
diff "$HOME/$fileName.bak" "$HOME/$fileName"
echo "====================="
fi
done
cp "$INSTALL_DIR/templates/zshrc.zsh-template" "$HOME/.zshrc"
sed -E "s/^source\ \\\$ZSH\/oh-my-zsh.sh$//g" -i "$HOME/.zshrc"
echo -e "[[ -r \"\$HOME/.zshrc.local\" ]] && source \"\$HOME/.zshrc.local\"" >>"$HOME/.zshrc"
chsh -s /bin/zsh "$(whoami)"