-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstow.sh
More file actions
executable file
·128 lines (106 loc) · 2.89 KB
/
stow.sh
File metadata and controls
executable file
·128 lines (106 loc) · 2.89 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
#!/usr/bin/env bash
# Stow-based dotfiles management
# Usage: ./stow.sh [install|uninstall|restow]
set -e
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
print_status() {
echo -e "${GREEN}[✓]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[!]${NC} $1"
}
print_error() {
echo -e "${RED}[✗]${NC} $1"
}
check_stow() {
if ! command -v stow &> /dev/null; then
print_error "GNU Stow is not installed."
echo "Install it with:"
echo " macOS: brew install stow"
echo " Ubuntu: sudo apt install stow"
exit 1
fi
}
install_ai_rulez() {
echo " Setting up .ai-rulez..."
# Create ~/.config if it doesn't exist
mkdir -p "$HOME/.config"
# Remove existing symlink or directory
if [ -L "$HOME/.config/ai-rulez" ]; then
rm "$HOME/.config/ai-rulez"
elif [ -d "$HOME/.config/ai-rulez" ]; then
print_warning "~/.config/ai-rulez exists and is not a symlink. Backing up..."
mv "$HOME/.config/ai-rulez" "$HOME/.config/ai-rulez.backup.$(date +%s)"
fi
# Create symlink: dotfiles/.ai-rulez → ~/.config/ai-rulez
ln -s "$DOTFILES_DIR/.ai-rulez" "$HOME/.config/ai-rulez"
print_status ".ai-rulez → ~/.config/ai-rulez"
}
uninstall_ai_rulez() {
echo " Removing .ai-rulez..."
if [ -L "$HOME/.config/ai-rulez" ]; then
rm "$HOME/.config/ai-rulez"
print_status ".ai-rulez symlink removed"
else
print_warning "~/.config/ai-rulez is not a symlink, skipping"
fi
}
install_packages() {
check_stow
echo "Installing dotfiles packages..."
# ai-rulez: symlink to ~/.config/ai-rulez
if [ -d "$DOTFILES_DIR/.ai-rulez" ]; then
install_ai_rulez
fi
# Add more stow packages here if needed
# Example: stow -v -d "$DOTFILES_DIR" -t "$HOME" "some-package"
print_status "All packages installed!"
}
uninstall_packages() {
check_stow
echo "Uninstalling dotfiles packages..."
# ai-rulez
uninstall_ai_rulez
print_status "All packages uninstalled!"
}
restow_packages() {
echo "Restowing dotfiles packages..."
uninstall_packages
install_packages
}
show_usage() {
echo "Usage: $0 [command]"
echo ""
echo "Commands:"
echo " install - Create symlinks for all packages (default)"
echo " uninstall - Remove all symlinks"
echo " restow - Recreate all symlinks (useful after adding new files)"
echo ""
echo "Packages managed:"
echo " .ai-rulez → ~/.config/ai-rulez"
}
# Main
case "${1:-install}" in
install)
install_packages
;;
uninstall)
uninstall_packages
;;
restow)
restow_packages
;;
help|--help|-h)
show_usage
;;
*)
print_error "Unknown command: $1"
show_usage
exit 1
;;
esac