-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-dotfiles.sh
executable file
·101 lines (89 loc) · 2.52 KB
/
setup-dotfiles.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
#!/bin/bash
function PrintStatus() {
local name="$1"
local status="$2"
local color="$3"
local color_code=""
local offset_arg="%-15s"
case "$color" in
"yellow")
color_code="\e[33m"
;;
"green")
color_code="\e[32m"
;;
"red")
color_code="\e[31m"
;;
*)
color_code="\e[0m" # Defaults to no color
;;
esac
local reset_color="\e[0m"
printf "| ${offset_arg} > %b%s%b\n" "${name}" "${color_code}${status}${reset_color}"
}
function DoLink() {
local name="$1"
local custom_path="$2"
if [ -z "$custom_path" ]; then
# Linking directly to the home directory (~)
if [ -e "$HOME/$name" ] && [ -z "$force" ]; then
PrintStatus "${name}" "skipped" "yellow"
return
else
if [ -n "$force" ]; then
PrintStatus "${name}" "forced" "red"
else
PrintStatus "${name}" "added" "green"
fi
ln -sf "$HOME/Dev/dotfiles/$name" "$HOME/$name"
fi
else
# Linking to the custom path
if [ -e "$HOME/$custom_path/$name" ] && [ -z "$force" ]; then
PrintStatus "${name}" "skipped" "yellow"
else
if [ -n "$force" ]; then
PrintStatus "${name}" "forced" "red"
else
PrintStatus "${name}" "added" "green"
fi
ln -sf "$HOME/Dev/dotfiles/$custom_path/$name" "$HOME/$custom_path/$name"
fi
fi
}
# Parse command-line arguments
force=""
if [ "$#" -gt 0 ]; then
if [ "$1" == "-force" ] || [ "$1" == "-f" ]; then
force="true"
else
echo -e "\e[1m\e[31mError:\e[0m Unsupported option. Use '-force' or '-f' to force link files."
exit 1
fi
fi
# Main program
echo "Linking dotfiles to their respective places."
echo -e "\nLinking \"~/\" (home) dir"
DoLink ".xinitrc"
DoLink ".zprofile"
DoLink ".screenlayout"
DoLink ".zshrc"
DoLink ".sanyok"
config_dir=".config"
echo -e "\nLinking \"~/$config_dir\" dir"
DoLink "user-dirs.dirs" "$config_dir"
DoLink "fontconfig" "$config_dir"
DoLink "picom" "$config_dir"
DoLink "bspwm" "$config_dir"
DoLink "sxhkd" "$config_dir"
DoLink "polybar" "$config_dir"
DoLink "rofi" "$config_dir"
DoLink "nitrogen" "$config_dir"
DoLink "dunst" "$config_dir"
DoLink "kitty" "$config_dir"
DoLink "neofetch" "$config_dir"
DoLink "nvim" "$config_dir"
DoLink "mpv" "$config_dir"
DoLink "btop" "$config_dir"
echo -e "\nComplete!"