-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·92 lines (77 loc) · 2.57 KB
/
setup.sh
File metadata and controls
executable file
·92 lines (77 loc) · 2.57 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
#!/bin/bash
# Define URLs for the repositories
urls=(
"https://github.com/AnantStrange/dwm.git"
"https://github.com/AnantStrange/dwmblocks.git"
"https://github.com/AnantStrange/dmenu.git"
"https://github.com/AnantStrange/tabbed.git"
"https://github.com/AnantStrange/st.git"
"https://github.com/AnantStrange/password-store.git"
"https://github.com/AnantStrange/dotfiles.git"
"https://github.com/AnantStrange/scripts.git"
"https://github.com/AnantStrange/Wallpapers.git"
)
# Define categories
wm_repos=("dwm" "dwmblocks" "dmenu" "tabbed" "st")
general_repos=("dotfiles" "scripts")
misc_repos=("password-store","Wallpapers")
# Function to prompt user for confirmation
prompt_user() {
local category="$1"
read -p "Do you want to clone $category repositories? (y/n): " choice
case "$choice" in
y|Y) return 0 ;;
n|N) return 1 ;;
*) echo "Invalid choice. Please enter y or n." ; prompt_user "$category" ;;
esac
}
# Function to clone repositories
clone_repos() {
local category="$1"
local repos=("${!2}")
local target_dir="$3"
echo "Cloning $category repositories into $target_dir..."
mkdir -p "$target_dir"
for repo in "${repos[@]}"; do
for url in "${urls[@]}"; do
if [[ "$url" == *"$repo"* ]]; then
echo "Cloning $repo..."
git clone "$url" "$target_dir/$repo"
break
fi
done
done
}
# Function to install WM-related repositories
install_wm_repos() {
local wm_dir="$HOME/wm"
for repo in "${wm_repos[@]}"; do
echo "Installing $repo..."
cd "$wm_dir/$repo" || { echo "Failed to cd into $wm_dir/$repo"; exit 1; }
sudo make clean install
done
}
# Function to handle dotfiles submodule
handle_dotfiles_submodule() {
local dotfiles_dir="$HOME/.dotfiles"
echo "Initializing and updating submodules for dotfiles..."
cd "$dotfiles_dir" || { echo "Failed to cd into $dotfiles_dir"; exit 1; }
git submodule update --init --recursive
}
# Main script logic
# Clone WM-related repositories
if prompt_user "Window Manager"; then
clone_repos "Window Manager" wm_repos[@] "$HOME/wm"
install_wm_repos
fi
# Clone General repositories
if prompt_user "General"; then
clone_repos "General" general_repos[@] "$HOME/.dotfiles"
handle_dotfiles_submodule
clone_repos "General" general_repos[@] "$HOME/scripts"
fi
# Clone Misc repositories
if prompt_user "Miscellaneous"; then
clone_repos "Miscellaneous" misc_repos[@] "$HOME/.local/share/.password-store"
fi
echo "Setup complete!"