-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.bash
More file actions
executable file
·50 lines (36 loc) · 1.08 KB
/
Copy pathinstall.bash
File metadata and controls
executable file
·50 lines (36 loc) · 1.08 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
#!/bin/bash +x
# Remove config if they exits
## Set the configuration arrays
declare -a local_config_dirs=()
declare -a config_dirs=()
declare -a matched_config_dirs=()
index_local_config=0
for config in config/*; do
IFS="/" read -ra config_tree <<< "$config"
local_config_dirs[index_local_config]="${config_tree[-1]}"
((index_local_config++))
done
unset 'index_local_config'
index_config=0
for config in ~/.config/*; do
IFS="/" read -ra config_tree <<< "$config"
config_dirs[index_config]="${config_tree[-1]}"
((index_config++))
done
unset 'index_config'
## Find the configs to remove
for local_config in "${local_config_dirs[@]}"; do
if [[ "${config_dirs[*]}" =~ "$local_config" ]]; then
rm -rf "$HOME/.config/$local_config"
echo "The $local_config was removed in the config_dirs"
fi
done
rm "$HOME/.zshrc"
echo "$HOME/.zshrc removed"
## Create the symbolic link in ~/.config/
for config in config/*; do
ln -sf "$PWD/$config" "$HOME/.config"
echo "link from $PWD/$config to $HOME/.config"
done
ln -sf "$PWD/.zshrc" "$HOME"
echo "link from $PWD/.zshrc to $HOME"