-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-claude.sh
More file actions
executable file
·62 lines (57 loc) · 1.59 KB
/
setup-claude.sh
File metadata and controls
executable file
·62 lines (57 loc) · 1.59 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
#!/bin/sh
set -e
# Working directory
cd $HOME
claude_dir="$HOME/.claude"
agents_dir="$HOME/.claude/agents"
settings_file="$HOME/.claude/settings.json"
# Fetch the submodules directory
git submodule update --init --recursive
#
# Setup the agents link
#
# 1. If .claude/agents exists and is non-empty, show error and exit
if [ -d "$agents_dir" ] && [ -n "$(ls -A "$agents_dir" 2>/dev/null)" ]; then
echo "$agents_dir is non empty - delete it and try again"
exit 1
fi
#
# 2. If .claude/agents exists (and we're still here, so it must be empty), remove it
if [ -d "$agents_dir" ]; then
echo "Removing empty directory $agents_dir"
rmdir "$agents_dir"
fi
#
# 3. If .claude exists, echo Hello world
if [ -d "$claude_dir" ]; then
cd $claude_dir && ln -s $HOME/.dotfiles/claude/agents
fi
#
#
# Add the notification hook
#
# 1. Check if jq is installed
if ! command -v jq >/dev/null 2>&1; then
echo "❌ Error: jq is required but not installed."
echo "Please install it with: brew install jq"
exit 1
fi
#
# 2. Create settings.json if it doesn't exist
if [ ! -f "$settings_file" ]; then
echo '{}' > "$settings_file"
fi
#
# 3. Use jq to ensure the Notification hook exists
jq '.hooks.Notification = [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "osascript -e \"display notification \\\"Claude Code needs your attention\\\" with title \\\"Claude Code\\\"\""
}
]
}
]' "$settings_file" > "$settings_file.tmp" && mv "$settings_file.tmp" "$settings_file"
echo "✅ Notification hook configured in $settings_file"