-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotfiles.sh
executable file
·41 lines (33 loc) · 1.17 KB
/
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
#!/bin/bash
# Define the dotfiles directory (replace with your actual dotfiles directory)
dotfiles_dir="$HOME/dotfiles"
# An associative array mapping files in your dotfiles directory to their desired locations
declare -A symlink_targets=(
["caps2esc.yaml"]="/etc/caps2esc.yaml"
["caps2esc.service"]="/etc/systemd/system/caps2esc.service"
["zshrc"]="$HOME/.zshrc"
["os.zsh"]="$HOME/.os.zsh"
["p10k.zsh"]="$HOME/.p10k.zsh"
["wezterm"]="$HOME/.wezterm"
["nvim.linux"]="$HOME/.config/nvim"
["file3"]="/etc/file3" # Example for a file to be linked in /etc
)
# Loop through the associative array
for file in "${!symlink_targets[@]}"; do
src="$dotfiles_dir/$file"
dst="${symlink_targets[$file]}"
# Check if the source file exists
if [ -f "$src" ]; then
# Create a backup of the destination file if it already exists
if [ -f "$dst" ]; then
echo "Backing up $dst to ${dst}.bak"
mv "$dst" "${dst}.bak"
fi
# Create the symlink
ln -s "$src" "$dst"
echo "Created symlink for $file"
else
echo "Source file $src not found. Skipping."
fi
done
echo "Symlinking complete."