Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·147 lines (126 loc) · 3.74 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·147 lines (126 loc) · 3.74 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env bash
# Dotfiles Setup Script for macOS/Linux
set -e
echo "Setting up dotfiles..."
# Check required dependencies
echo ""
echo "Checking dependencies..."
missing=""
if ! command -v git &> /dev/null; then
missing="$missing git"
fi
if ! command -v clang &> /dev/null; then
missing="$missing clang"
fi
if [ -n "$missing" ]; then
echo " Missing:$missing"
echo " Install before continuing."
exit 1
fi
echo " All dependencies found"
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
NVIM_TARGET="$HOME/.config/nvim"
NEOVIDE_TARGET="$HOME/.config/neovide"
WEZTERM_TARGET="$HOME/.config/wezterm"
CLAUDE_TARGET="$HOME/.claude"
create_symlink() {
local source="$1"
local target="$2"
local name="$3"
if [ -e "$target" ] || [ -L "$target" ]; then
echo " $name exists at $target"
read -p " Replace? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf "$target"
else
echo " Skipping $name"
return
fi
fi
mkdir -p "$(dirname "$target")"
if ln -s "$source" "$target"; then
echo " Created: $target -> $source"
else
echo " Failed to create symlink for $name"
exit 1
fi
}
create_hardlink() {
local source="$1"
local target="$2"
local name="$3"
if [ -e "$target" ] || [ -L "$target" ]; then
echo " $name exists at $target"
read -p " Replace? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -f "$target"
else
echo " Skipping $name"
return
fi
fi
if ln "$source" "$target"; then
echo " Created: $target -> $source"
else
echo " Failed to create hard link for $name"
exit 1
fi
}
echo ""
echo "Creating symlinks..."
create_symlink "$DOTFILES_DIR/.config/nvim" "$NVIM_TARGET" "Neovim"
create_symlink "$DOTFILES_DIR/.config/neovide" "$NEOVIDE_TARGET" "Neovide"
create_symlink "$DOTFILES_DIR/.config/wezterm" "$WEZTERM_TARGET" "WezTerm"
create_symlink "$DOTFILES_DIR/.config/git" "$HOME/.config/git" "Git Config"
echo ""
echo "Setting up Claude Code config..."
if [ ! -d "$CLAUDE_TARGET" ]; then
mkdir -p "$CLAUDE_TARGET"
echo " Created Claude directory: $CLAUDE_TARGET"
fi
create_hardlink "$DOTFILES_DIR/claude-config/CLAUDE.md" "$CLAUDE_TARGET/CLAUDE.md" "CLAUDE.md"
create_hardlink "$DOTFILES_DIR/claude-config/settings.local.json" "$CLAUDE_TARGET/settings.local.json" "settings.local.json"
echo ""
echo "Configuring PATH..."
# Detect OS for bin directory
if [[ "$OSTYPE" == "darwin"* ]]; then
BIN_DIR="$DOTFILES_DIR/bin/macos"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
BIN_DIR="$DOTFILES_DIR/bin/linux"
else
echo " Unsupported OS: $OSTYPE"
exit 1
fi
if [ -n "$ZSH_VERSION" ]; then
SHELL_CONFIG="$HOME/.zshrc"
elif [ -n "$BASH_VERSION" ]; then
if [ -f "$HOME/.bash_profile" ]; then
SHELL_CONFIG="$HOME/.bash_profile"
else
SHELL_CONFIG="$HOME/.bashrc"
fi
else
SHELL_CONFIG="$HOME/.profile"
fi
if ! grep -q "export PATH=\"$BIN_DIR:\$PATH\"" "$SHELL_CONFIG" 2>/dev/null; then
echo "" >> "$SHELL_CONFIG"
echo "# Dotfiles bin directory" >> "$SHELL_CONFIG"
echo "export PATH=\"$BIN_DIR:\$PATH\"" >> "$SHELL_CONFIG"
echo " Added $BIN_DIR to PATH in $SHELL_CONFIG"
echo " Restart terminal or run: source $SHELL_CONFIG"
else
echo " bin directory already in PATH"
fi
echo ""
echo "Setup complete!"
if ! command -v nvim &> /dev/null; then
echo ""
echo "Warning: Neovim not installed."
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Install: brew install neovim"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Install: apt install neovim, pacman -S neovim, etc."
fi
fi