-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_setup.sh
More file actions
executable file
·31 lines (26 loc) · 827 Bytes
/
Copy path_setup.sh
File metadata and controls
executable file
·31 lines (26 loc) · 827 Bytes
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
#!/bin/bash
set -euo pipefail
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
link_file() {
local src="$1"
local dest="$2"
# If dest exists and is not the correct symlink, back it up
if [ -e "$dest" ] && [ ! -L "$dest" ]; then
echo "Backing up $dest -> $dest.backup"
mv "$dest" "$dest.backup"
fi
# If symlink exists but points elsewhere, replace it
if [ -L "$dest" ]; then
current="$(readlink "$dest")"
if [ "$current" != "$src" ]; then
echo "Updating symlink $dest -> $src"
rm "$dest"
ln -s "$src" "$dest"
fi
else
echo "Creating symlink $dest -> $src"
ln -s "$src" "$dest"
fi
}
link_file "$DOTFILES_DIR/config" "$HOME/.config"
link_file "$DOTFILES_DIR/zprofile" "$HOME/.zprofile"