-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.sh
executable file
·84 lines (77 loc) · 2.05 KB
/
config.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
#!/bin/bash
cur_path=$(pwd)
dot_cache=~/.cache/dotsave
declare -A dict
# key: part of path value: command
dict=(
# desktop environment
[hypr]=Hyprland
[local]=Hyprland
[libinput]=Hyprland
[MangoHud]=mangohud
[swaylock]=swaylock
[hyde]=Hyde
[dunst]=dunst
[wlogout]=wlogout
[waybar]=waybar
[swww]=swww
[qt5ct]=qt5ct
[qt6ct]=qt6ct
[rofi]=rofi
["nwg-look"]=nwg-look
[themes]=nwg-look
[gtk]=nwg-look
[xsettingsd]=nwg-look
[Kvantum]=kvantummanager
# tools
[nvim]=nvim
[editorconfig]=nvim
[fcitx5]=fcitx5
[alacritty]=alacritty
[mpv]=mpv
[kitty]=kitty
[fastfetch]=fastfetch
["/.zsh"]=zsh
[fish]=fish
[starship]=starship
[gdb]=gdb
[pip]=pip
[npm]=npm
[cargo]=cargo
[chrome]=google-chrome-stable
)
get_dir() {
for element in $(ls -A $1); do
path="$1/$element"
home_path=${path/"$cur_path/configs"/"$HOME"}
if [[ $path =~ ".config/" ]] || [[ $path =~ ".bash_it/" ]] || [[ $path =~ ".themes/" ]] || [ -f $path ]; then
parent_path=$(dirname $home_path)
for key in ${!dict[@]}; do
value=${dict[$key]}
if [[ $path =~ $key ]] && command -v "${value}" >/dev/null 2>&1; then
[ ! -d $parent_path ] && mkdir -p $parent_path && echo mkdir -p $parent_path done!
[ -d $path ] && [ -d $home_path ] && rm -rf $home_path && rm -rf $home_path done!
ln -sf $path $home_path && echo "ln -sf $path $home_path done!"
echo $home_path >>$dot_cache
break
fi
done
# echo $target
if [[ $path =~ $key ]]; then
continue
fi
fi
if [ -d $path ]; then
get_dir $path
fi
done
}
if [ $1 == "install" ]; then
rm $dot_cache
get_dir "$cur_path/configs"
fi
if [ $1 == "uninstall" ]; then
while read line; do
rm -rf $line && echo "rm -rf $line done!"
done <$dot_cache
fi