-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate.sh
More file actions
executable file
·71 lines (59 loc) · 1.66 KB
/
migrate.sh
File metadata and controls
executable file
·71 lines (59 loc) · 1.66 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
# Migration script to update symlinks from old structure to new stow structure.
# This removes old symlinks and re-stows using the new dotfiles/ layout.
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
print_success() {
printf "\e[0;32m [✔] %s\e[0m\n" "$1"
}
print_info() {
printf "\e[0;34m [i] %s\e[0m\n" "$1"
}
# Old symlinks that pointed to home/ directory
OLD_HOME_FILES=(
".zshrc"
".p10k.zsh"
".tmux.conf"
".vimrc"
".main.gitconfig"
".gitignore"
".ignore"
".ripgreprc"
".editorconfig"
)
# Old symlinks that pointed to config/ directory
OLD_CONFIG_DIRS=(
"nvim"
)
echo "Migration: Old structure → Stow structure"
echo "=========================================="
# Remove old home directory symlinks
print_info "Removing old symlinks from home directory..."
for file in "${OLD_HOME_FILES[@]}"; do
target="${HOME}/${file}"
if [[ -L "${target}" ]]; then
rm "${target}"
print_success "Removed ${target}"
fi
done
# Remove old .config symlinks
print_info "Removing old symlinks from ~/.config..."
for dir in "${OLD_CONFIG_DIRS[@]}"; do
target="${HOME}/.config/${dir}"
if [[ -L "${target}" ]]; then
rm "${target}"
print_success "Removed ${target}"
fi
done
# Clean up old gitconfig include if present
if grep -q "path=~/.main.gitconfig" "${HOME}/.gitconfig" 2>/dev/null; then
print_info "Removing old gitconfig include..."
sed -i '/\[include\]/d; /path=~\/.main.gitconfig/d' "${HOME}/.gitconfig"
# Remove file if empty
if [[ ! -s "${HOME}/.gitconfig" ]]; then
rm "${HOME}/.gitconfig"
fi
print_success "Cleaned up ~/.gitconfig"
fi
echo
print_info "Now run ./install.sh to stow the new structure"