-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·109 lines (93 loc) · 3.44 KB
/
install.sh
File metadata and controls
executable file
·109 lines (93 loc) · 3.44 KB
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
#!/bin/bash
# Navigate to the dotfiles directory
cd ~/src/dotfiles
# Define an array of packages to stow
PACKAGES=("git" "nvim" "tmux" "zsh" "zsh-themes")
# Check if stow is installed
if ! command -v stow &> /dev/null; then
echo "stow could not be found. Please install it first (e.g., sudo apt install stow)."
exit 1
fi
# Function to handle overwriting existing files
handle_overwrite() {
local target_path="$1"
# Check if the target path exists and is not a symlink to the correct source
if [ -e "$target_path" ] && [ ! -L "$target_path" ]; then
read -p "$target_path already exists. Do you want to remove it to create a symlink? (y/N): " choice
case "$choice" in
y|Y )
echo "Removing $target_path..."
rm -rf "$target_path"
;;
* )
echo "Skipping symlink creation for $target_path."
return 1
;;
esac
fi
return 0
}
# --- Check and install TPM (Tmux Plugin Manager) and Catppuccin theme ---
if [[ " ${PACKAGES[@]} " =~ " tmux " ]]; then
TPM_PATH="$HOME/.tmux/plugins/tpm"
if [ ! -d "$TPM_PATH" ]; then
echo "TPM not found. Installing it to $TPM_PATH..."
mkdir -p "$HOME/.tmux/plugins"
git clone https://github.com/tmux-plugins/tpm "$TPM_PATH"
echo "TPM installed successfully."
else
echo "TPM is already installed."
fi
CATPPUCCIN_PATH="$HOME/.config/tmux/plugins/catppuccin/tmux"
if [ ! -d "$CATPPUCCIN_PATH" ]; then
echo "Catppuccin theme not found. Installing it to $CATPPUCCIN_PATH..."
mkdir -p "$HOME/.config/tmux/plugins/catppuccin"
git clone -b v2.1.3 https://github.com/catppuccin/tmux.git "$CATPPUCCIN_PATH"
echo "Catppuccin theme installed successfully."
else
echo "Catppuccin theme is already installed."
fi
fi
# Loop through each package and stow it
for pkg in "${PACKAGES[@]}"; do
if [ "$pkg" == "nvim" ]; then
# Special handling for Neovim
NVIM_DEST="$HOME/.config/nvim"
echo "Handling Neovim configuration..."
mkdir -p "$NVIM_DEST"
files_to_check=$(find "$pkg" -maxdepth 1 -mindepth 1)
for file in $files_to_check; do
target_path="$NVIM_DEST/$(basename "$file")"
if ! handle_overwrite "$target_path"; then
continue 2
fi
done
echo "Stowing nvim..."
stow -v --target="$NVIM_DEST" "$pkg"
elif [ "$pkg" == "zsh-themes" ]; then
# Special handling for zsh themes
ZSH_THEMES_DEST="$HOME/.oh-my-zsh/themes"
echo "Handling zsh themes configuration..."
mkdir -p "$ZSH_THEMES_DEST"
files_to_check=$(find "$pkg" -maxdepth 1 -mindepth 1)
for file in $files_to_check; do
target_path="$ZSH_THEMES_DEST/$(basename "$file")"
if ! handle_overwrite "$target_path"; then
continue 2
fi
done
echo "Stowing zsh themes..."
stow -v --target="$ZSH_THEMES_DEST" "$pkg"
else
# General handling for other packages (git, tmux, zsh)
echo "Stowing $pkg..."
pkg_files=$(find "$pkg" -maxdepth 1 -mindepth 1)
for file in $pkg_files; do
target_path="$HOME/$(basename "$file")"
if ! handle_overwrite "$target_path"; then
continue 2
fi
done
stow -v --target="$HOME" "$pkg"
fi
done