-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·76 lines (64 loc) · 1.99 KB
/
setup.sh
File metadata and controls
executable file
·76 lines (64 loc) · 1.99 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
72
73
74
75
76
#!/bin/bash
# Dotfiles setup script
# This script sets up symlinks for all dotfiles and installs dependencies
set -e
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BACKUP_DIR="$HOME/.dotfiles_backup_$(date +%Y%m%d_%H%M%S)"
echo "Setting up dotfiles from $DOTFILES_DIR"
# Function to create symlink with backup
create_symlink() {
local source="$1"
local target="$2"
if [ -e "$target" ] && [ ! -L "$target" ]; then
echo " Backing up existing $target to $BACKUP_DIR"
mkdir -p "$BACKUP_DIR"
mv "$target" "$BACKUP_DIR/"
elif [ -L "$target" ]; then
echo " Removing existing symlink $target"
rm "$target"
fi
echo " Creating symlink: $target -> $source"
ln -s "$source" "$target"
}
# Create symlinks for all dotfiles
echo ""
echo "Creating symlinks for dotfiles..."
for file in "$DOTFILES_DIR"/.*; do
# Skip . and .. and .git directory
basename=$(basename "$file")
if [[ "$basename" == "." || "$basename" == ".." || "$basename" == ".git" || "$basename" == ".gitignore" ]]; then
continue
fi
# Skip if it's a directory (except we want to link files)
if [ -f "$file" ]; then
create_symlink "$file" "$HOME/$basename"
fi
done
# Install git-chord
echo ""
echo "Installing git-chord..."
GIT_CHORD_DIR="$HOME/.git-chord"
if [ -d "$GIT_CHORD_DIR" ]; then
echo " git-chord already exists at $GIT_CHORD_DIR"
read -p " Update it? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo " Updating git-chord..."
cd "$GIT_CHORD_DIR"
git pull
cd "$DOTFILES_DIR"
fi
else
echo " Cloning git-chord to $GIT_CHORD_DIR..."
git clone https://github.com/socket-link/git-chord.git "$GIT_CHORD_DIR"
fi
echo ""
echo "Setup complete!"
echo ""
if [ -d "$BACKUP_DIR" ]; then
echo "Your original dotfiles have been backed up to: $BACKUP_DIR"
echo ""
fi
echo "To apply the changes, either:"
echo " 1. Restart your terminal, or"
echo " 2. Run: source ~/.zshrc"