-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupDots
More file actions
executable file
·144 lines (117 loc) · 4.11 KB
/
setupDots
File metadata and controls
executable file
·144 lines (117 loc) · 4.11 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
#!/usr/bin/env bash
set -euo pipefail
# Color variables
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
run_command() {
echo -e "${YELLOW}Running:${NC} $*"
"$@"
}
complete_message() {
echo -e "${GREEN}$1 completed.${NC}"
}
remove_broken_symlinks() {
local target_dir="$1"
while IFS= read -r -d '' link; do
local target
target=$(readlink "$link")
if [[ $target == *"dotfiles"* ]]; then
echo -e "${YELLOW}Removing broken symlink:${NC} $link -> $target"
rm -f "$link"
fi
done < <(find "$target_dir" -type l -xtype l -print0 2>/dev/null)
}
user_config() {
run_command mkdir -p ~/.config ~/.local ~/.gemini/skills ~/.gemini/antigravity ~/.kilocode/skills ~/.agents
remove_broken_symlinks ~/.local
run_command stow --dir "$PWD" --target ~/.local --restow --no-folding .local
remove_broken_symlinks ~/.claude
remove_broken_symlinks ~/.gemini
remove_broken_symlinks ~/.gemini/antigravity
remove_broken_symlinks ~/.kilocode
run_command stow --dir "$PWD" --target ~ --restow --no-folding home
# Create symlink for opencode skills to share with claude skills
# Must be after home stow so ~/.claude/skills exists as a symlink first
run_command mkdir -p ~/.config/opencode
rm -f ~/.config/opencode/skills
run_command ln -s ~/.claude/skills ~/.config/opencode/skills
# Share Claude skills with Codex
# Must be after home stow so ~/.claude/skills exists as a symlink first
rm -f ~/.agents/skills
run_command ln -s ~/.claude/skills ~/.agents/skills
# Share Claude skills with Antigravity
# Must be after home stow so ~/.claude/skills exists as a symlink first
rm -rf ~/.gemini/antigravity/skills
run_command ln -s ~/.claude/skills ~/.gemini/antigravity/skills
# Share Claude skills with Kilocode
# Must be after home stow so ~/.claude/skills exists as a symlink first
rm -rf ~/.kilocode/skills
run_command ln -s ~/.claude/skills ~/.kilocode/skills
remove_broken_symlinks ~/.config
run_command stow --dir "$PWD" --target ~/.config --restow .config
if [[ "$(uname)" == "Linux" ]]; then
run_command systemctl --user enable ssh-agent
run_command systemctl --user start ssh-agent
fi
}
linux_system_config() {
run_command sudo ln -sf "$PWD"/misc/keymaps/colemak /usr/share/X11/xkb/symbols/colemak
run_command sudo ln -sf "$PWD"/misc/keymaps/keyd.conf /etc/keyd/default.conf
run_command sudo mkdir -p -m 755 \
/etc/systemd/sleep.conf.d/ \
/etc/systemd/logind.conf.d/ \
/etc/systemd/resolved.conf.d/
# Systemd runs in a sandbox and does not have access to user directories by default.
# That's why we copy things
run_command sudo rm -f /etc/systemd/sleep.conf.d/99-sleep.conf
run_command sudo cp -f "$PWD"/misc/systemd-config/99-sleep.conf /etc/systemd/sleep.conf.d/
# sudoers
run_command sudo ln -sf "$PWD"/misc/99-sudoers /etc/sudoers.d/
run_command sudo chown root:root /etc/sudoers.d/99-sudoers
# logind
run_command sudo rm -f /etc/systemd/logind.conf.d/99-logind.conf
run_command sudo cp -f "$PWD"/misc/systemd-config/99-logind.conf /etc/systemd/logind.conf.d/
run_command sudo sed -i '/Color/s/^#//g' /etc/pacman.conf
run_command sudo ln -sfT "$PWD"/misc/pacman-hooks /etc/pacman.d/hooks
run_command sudo ln -sfT dash /usr/bin/sh
}
mac_system_config() {
echo -e "${YELLOW}No macOS-specific automation is defined yet.${NC}"
echo -e "${YELLOW}Add tasks here when macOS setup steps are available.${NC}"
}
run() {
local option="${1:-}"
local -r options=("User Configuration" "Linux (Arch) System Configuration" "Mac System Configuration" "Quit")
if [[ -z $option ]]; then
echo -e "${YELLOW}Select an option:${NC}"
select _ in "${options[@]}"; do
option=$REPLY
break
done
fi
case "$option" in
1)
user_config
complete_message "${options[0]}"
;;
2)
linux_system_config
complete_message "${options[1]}"
;;
3)
mac_system_config
complete_message "${options[2]}"
;;
4 | q | quit)
return 0
;;
*)
echo -e "${RED}Invalid option: ${option}${NC}"
[[ -n ${1:-} ]] && echo "Usage: $0 [1|2|3|4]"
return 2
;;
esac
}
run "${1:-}"