-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsync_dotfiles
More file actions
executable file
·38 lines (28 loc) · 1.07 KB
/
sync_dotfiles
File metadata and controls
executable file
·38 lines (28 loc) · 1.07 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
#!/bin/zsh
#
# Idempotent, safe symlinking of config files.
DOTFILES_DIR=$(cd "$(dirname "$0")" && pwd)
link_file() {
local src="$1"
local dest="$2"
mkdir -p "$(dirname "$dest")"
if [[ -f "$dest" && ! -L "$dest" ]]; then
echo " Backing up existing file: $dest to $dest.bak"
mv "$dest" "$dest.bak"
fi
# Create the symlink (-s), forcing it (-f) to update if it exists.
ln -sf "$src" "$dest"
echo "Linked: $dest -> $src"
}
echo "Starting dotfile synchronization..."
# --- Mappings ---
# link_file "SOURCE_IN_REPO" "TARGET_DESTINATION"
# Home directory files
link_file "$DOTFILES_DIR/.vimrc" "$HOME/.vimrc"
link_file "$DOTFILES_DIR/.zshenv" "$HOME/.zshenv"
link_file "$DOTFILES_DIR/.zshrc" "$HOME/.zshrc"
# .config directory files
link_file "$DOTFILES_DIR/starship.toml" "$HOME/.config/starship.toml"
link_file "$DOTFILES_DIR/config.ghostty" "$HOME/.config/ghostty/config.ghostty"
link_file "$DOTFILES_DIR/ghostty-dark.theme" "$HOME/.config/ghostty/themes/ghostty-dark.theme"
echo "Done. Restart your shell or source your config files."