-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·50 lines (37 loc) · 1.14 KB
/
setup.sh
File metadata and controls
executable file
·50 lines (37 loc) · 1.14 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
#!/bin/bash
# Dotfiles setup script
# Creates symlinks from this repo to the appropriate config locations
DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Setting up dotfiles from $DOTFILES_DIR"
# Backup existing configs
backup_if_exists() {
if [ -e "$1" ] && [ ! -L "$1" ]; then
echo "Backing up existing $1 to $1.backup"
mv "$1" "$1.backup"
fi
}
# Create symlink
create_symlink() {
local source="$1"
local target="$2"
# Create parent directory if it doesn't exist
mkdir -p "$(dirname "$target")"
# Backup existing file/directory
backup_if_exists "$target"
# Remove existing symlink if it exists
if [ -L "$target" ]; then
rm "$target"
fi
# Create symlink
ln -s "$source" "$target"
echo "Created symlink: $target -> $source"
}
# Neovim config
create_symlink "$DOTFILES_DIR/nvim" "$HOME/.config/nvim"
# i3 config
create_symlink "$DOTFILES_DIR/i3" "$HOME/.config/i3"
# Tmux config
create_symlink "$DOTFILES_DIR/tmux/tmux.conf" "$HOME/.tmux.conf"
echo ""
echo "Dotfiles setup complete!"
echo "Any existing configs have been backed up with .backup extension"