-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
126 lines (108 loc) · 3.29 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
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
#!/bin/bash
set -e
[ "$DEBUG" == 'true' ] && set -x
INSTALL_PATH=$HOME
THEME_FILE=jungwoo.zsh-theme
THEME_PATH=$HOME/.oh-my-zsh/themes/
TPM_PATH="$HOME/.tmux/plugins/tpm"
FILES=(
".zshrc"
".tmux.conf"
".pdbrc"
".ipdb"
)
if ! command -v zsh &> /dev/null; then
echo "'zsh' is not found! Try 'sudo apt install zsh'."
exit
fi
# Function to log file updates
log_file_update() {
local file_name="$1"
local rsync_output="$2"
if [[ "$rsync_output" =~ ">" ]]; then
echo " $file_name was updated or copied."
else
echo " $file_name is latest"
fi
}
install_file() {
local SRC="$1"
local DEST="$2"
local output=$(rsync -ahu --itemize-changes "$SRC" "$DEST")
log_file_update "$SRC" "$output"
}
# Function to install files
install_files_to_home() {
echo "Installing files..."
for f in "${FILES[@]}"; do
install_file "$f" "$INSTALL_PATH/$f"
done
}
# Function to install Tmux plugins
install_tmux_plugins() {
echo "Installing Tmux plugins..."
if [ ! -d "$TPM_PATH" ]; then
git clone https://github.com/tmux-plugins/tpm $TPM_PATH
else
echo " TPM already installed, skipping..."
fi
# Start a new Tmux session to install plugins
if [ ! -f "$TPM_PATH/scripts/install_plugins.sh" ]; then
tmux start-server && \
tmux new-session -d && \
sleep 1 && \
$TPM_PATH/scripts/install_plugins.sh && \
tmux kill-server
else
echo " Tmux plugins already installed, skipping..."
fi
}
# Function to install Oh My Zsh
install_oh_my_zsh() {
echo "Installing Oh My Zsh..."
if [ ! -d "$HOME/.oh-my-zsh" ]; then
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" &
wait $!
else
echo " Oh My Zsh already installed, skipping..."
fi
}
# Function to install Zsh plugins
install_zsh_plugins() {
echo "Installing zsh plugins..."
# Install zsh-autosuggestions
TARGET="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions"
if [ ! -d $TARGET ]; then
git clone https://github.com/zsh-users/zsh-autosuggestions $TARGET
else
echo " Zsh autosuggestions plugin already installed, skipping..."
fi
# Install zsh-syntax-highlighting
TARGET="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting"
if [ ! -d $TARGET ]; then
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $TARGET
else
echo " Zsh syntax highlighting plugin already installed, skipping..."
fi
}
# install theme, must go after oh-my-zsh
install_theme() {
echo "Installing jungwoo theme..."
install_file $THEME_FILE $THEME_PATH
}
install_nvm() {
latest=$(curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$latest/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm install --lts
}
install() {
install_files_to_home
install_tmux_plugins
install_oh_my_zsh
install_zsh_plugins
install_theme
install_nvm
}
install