forked from devmatteini/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_symbolic_links.sh
executable file
·78 lines (62 loc) · 1.92 KB
/
create_symbolic_links.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
#!/usr/bin/env bash
if [ -z "$1" ];then
echo "Usage: $(basename "${BASH_SOURCE[0]}") <BASEDIR>"
exit 1
fi
BASEDIR=$1
FILES=(
"bash/.bash_aliases"
"bash/.bash_exports"
"bash/.bash_logout"
"bash/.bash_options"
"bash/.bash_profile"
"bash/.bash_prompt"
"bash/.bash_functions"
"bash/.bashrc"
"bash/.inputrc"
"git/.gitconfig"
"vim/.vimrc"
)
CONFIG_FILES=(
"config/starship.toml"
)
CONFIG_DIRS=(
"config/wezterm"
)
# NOTE: https://www.shellcheck.net/wiki/SC2207
readarray -t SCRIPTS_FILES < <(find "$BASEDIR/scripts" -maxdepth 1 -type f -printf '%f\n')
echo -e "\e[1;34m[i] Creating symlinks in $HOME/ ...\e[0m"
for file in "${FILES[@]}"; do
sourceFile="$BASEDIR/$file"
targetFile="$HOME/$(printf "%s" "$file" | sed "s/.*\/\(.*\)/\1/g")"
ln -sfn "$sourceFile" "$targetFile"
done;
unset file;
echo -e "\e[1;34m[i] Creating symlinks in $HOME/.config/ ...\e[0m"
for file in "${CONFIG_FILES[@]}"; do
sourceFile="$BASEDIR/$file"
targetFile="$HOME/.config/$(printf "%s" "$file" | sed "s/.*\/\(.*\)/\1/g")"
ln -sfn "$sourceFile" "$targetFile"
done;
unset file;
echo -e "\e[1;34m[i] Creating directories in $HOME/.config/ ...\e[0m"
for dir in "${CONFIG_DIRS[@]}"; do
sourceDir="$BASEDIR/$dir"
targetDir="$HOME/.config/$(printf "%s" "$dir" | sed "s/.*\/\(.*\)/\1/g")"
mkdir -p "$targetDir"
files=($(ls -A "$sourceDir"))
echo -e "\e[1;34m [i] Creating symlinks in $targetDir ...\e[0m"
for file in "${files[@]}"; do
sourceFile="$sourceDir/$file"
targetFile="$targetDir/$file"
ln -sfn "$sourceFile" "$targetFile"
done;
done;
echo -e "\e[1;34m[i] Creating symlinks in $HOME/.local/bin ...\e[0m"
for file in "${SCRIPTS_FILES[@]}"; do
sourceFile="$BASEDIR/scripts/$file"
targetFile="$HOME/.local/bin/$file"
ln -sfn "$sourceFile" "$targetFile"
done;
unset file;
echo -e "\e[1;32m[✓] Symlinks created succesfully.\e[0m"