44# Re-running updates core files; sounds are version-controlled in the repo
55set -euo pipefail
66
7- INSTALL_DIR=" $HOME /.claude/hooks/peon-ping"
8- SETTINGS=" $HOME /.claude/settings.json"
7+ LOCAL_MODE=false
8+ for arg in " $@ " ; do
9+ case " $arg " in
10+ --local) LOCAL_MODE=true ;;
11+ esac
12+ done
13+
14+ if [ " $LOCAL_MODE " = true ]; then
15+ BASE_DIR=" $PWD /.claude"
16+ else
17+ BASE_DIR=" $HOME /.claude"
18+ fi
19+ INSTALL_DIR=" $BASE_DIR /hooks/peon-ping"
20+ SETTINGS=" $BASE_DIR /settings.json"
921REPO_BASE=" https://raw.githubusercontent.com/tonyyont/peon-ping/main"
1022
1123# All available sound packs (add new packs here)
12- PACKS=" peon peon_fr peon_pl peasant peasant_fr ra2_soviet_engineer sc_battlecruiser sc_kerrigan tf2_engineer"
24+ PACKS=" acolyte_ru peon peon_fr peon_pl peon_ru peasant peasant_fr peasant_ru ra2_soviet_engineer sc_battlecruiser sc_kerrigan tf2_engineer"
1325
1426# --- Platform detection ---
1527detect_platform () {
@@ -68,8 +80,12 @@ elif [ "$PLATFORM" = "wsl" ]; then
6880 fi
6981fi
7082
71- if [ ! -d " $HOME /.claude" ]; then
72- echo " Error: ~/.claude/ not found. Is Claude Code installed?"
83+ if [ ! -d " $BASE_DIR " ]; then
84+ if [ " $LOCAL_MODE " = true ]; then
85+ echo " Error: .claude/ not found in current directory. Is this a Claude Code project?"
86+ else
87+ echo " Error: ~/.claude/ not found. Is Claude Code installed?"
88+ fi
7389 exit 1
7490fi
7591
133149chmod +x " $INSTALL_DIR /peon.sh"
134150
135151# --- Install skill (slash command) ---
136- SKILL_DIR=" $HOME /.claude /skills/peon-ping-toggle"
152+ SKILL_DIR=" $BASE_DIR /skills/peon-ping-toggle"
137153mkdir -p " $SKILL_DIR "
154+ if [ " $LOCAL_MODE " = true ]; then
155+ SKILL_HOOK_CMD=" bash .claude/hooks/peon-ping/peon.sh"
156+ else
157+ SKILL_HOOK_CMD=" bash ~/.claude/hooks/peon-ping/peon.sh"
158+ fi
138159if [ -n " $SCRIPT_DIR " ] && [ -d " $SCRIPT_DIR /skills/peon-ping-toggle" ]; then
139160 cp " $SCRIPT_DIR /skills/peon-ping-toggle/SKILL.md" " $SKILL_DIR /"
161+ if [ " $LOCAL_MODE " = true ]; then
162+ sed -i.bak ' s|bash ~/.claude/hooks/peon-ping/peon.sh|' " $SKILL_HOOK_CMD " ' |g' " $SKILL_DIR /SKILL.md"
163+ rm -f " $SKILL_DIR /SKILL.md.bak"
164+ fi
140165elif [ -z " $SCRIPT_DIR " ]; then
141166 curl -fsSL " $REPO_BASE /skills/peon-ping-toggle/SKILL.md" -o " $SKILL_DIR /SKILL.md"
167+ if [ " $LOCAL_MODE " = true ]; then
168+ sed -i.bak ' s|bash ~/.claude/hooks/peon-ping/peon.sh|' " $SKILL_HOOK_CMD " ' |g' " $SKILL_DIR /SKILL.md"
169+ rm -f " $SKILL_DIR /SKILL.md.bak"
170+ fi
142171else
143172 echo " Warning: skills/peon-ping-toggle not found in local clone, skipping skill install"
144173fi
145174
146- # --- Add shell alias ---
147- ALIAS_LINE=' alias peon="bash ~/.claude/hooks/peon-ping/peon.sh"'
148- for rcfile in " $HOME /.zshrc" " $HOME /.bashrc" ; do
149- if [ -f " $rcfile " ] && ! grep -qF ' alias peon=' " $rcfile " ; then
150- echo " " >> " $rcfile "
151- echo " # peon-ping quick controls" >> " $rcfile "
152- echo " $ALIAS_LINE " >> " $rcfile "
153- echo " Added peon alias to $( basename " $rcfile " ) "
154- fi
155- done
175+ # --- Add shell alias (global install only) ---
176+ if [ " $LOCAL_MODE " = false ]; then
177+ ALIAS_LINE=' alias peon="bash ~/.claude/hooks/peon-ping/peon.sh"'
178+ for rcfile in " $HOME /.zshrc" " $HOME /.bashrc" ; do
179+ if [ -f " $rcfile " ] && ! grep -qF ' alias peon=' " $rcfile " ; then
180+ echo " " >> " $rcfile "
181+ echo " # peon-ping quick controls" >> " $rcfile "
182+ echo " $ALIAS_LINE " >> " $rcfile "
183+ echo " Added peon alias to $( basename " $rcfile " ) "
184+ fi
185+ done
156186
157- # --- Add tab completion ---
158- COMPLETION_LINE=' [ -f ~/.claude/hooks/peon-ping/completions.bash ] && source ~/.claude/hooks/peon-ping/completions.bash'
159- for rcfile in " $HOME /.zshrc" " $HOME /.bashrc" ; do
160- if [ -f " $rcfile " ] && ! grep -qF ' peon-ping/completions.bash' " $rcfile " ; then
161- echo " $COMPLETION_LINE " >> " $rcfile "
162- echo " Added tab completion to $( basename " $rcfile " ) "
163- fi
164- done
187+ # --- Add tab completion ---
188+ COMPLETION_LINE=' [ -f ~/.claude/hooks/peon-ping/completions.bash ] && source ~/.claude/hooks/peon-ping/completions.bash'
189+ for rcfile in " $HOME /.zshrc" " $HOME /.bashrc" ; do
190+ if [ -f " $rcfile " ] && ! grep -qF ' peon-ping/completions.bash' " $rcfile " ; then
191+ echo " $COMPLETION_LINE " >> " $rcfile "
192+ echo " Added tab completion to $( basename " $rcfile " ) "
193+ fi
194+ done
195+ fi
165196
166197# --- Verify sounds are installed ---
167198echo " "
@@ -175,8 +206,8 @@ for pack in $PACKS; do
175206 fi
176207done
177208
178- # --- Backup existing notify.sh (fresh install only) ---
179- if [ " $UPDATING " = false ]; then
209+ # --- Backup existing notify.sh (global fresh install only) ---
210+ if [ " $LOCAL_MODE " = false ] && [ " $ UPDATING" = false ]; then
180211 NOTIFY_SH=" $HOME /.claude/hooks/notify.sh"
181212 if [ -f " $NOTIFY_SH " ]; then
182213 cp " $NOTIFY_SH " " $NOTIFY_SH .backup"
189220echo " "
190221echo " Updating Claude Code hooks in settings.json..."
191222
223+ if [ " $LOCAL_MODE " = true ]; then
224+ HOOK_CMD=" .claude/hooks/peon-ping/peon.sh"
225+ else
226+ HOOK_CMD=" $HOME /.claude/hooks/peon-ping/peon.sh"
227+ fi
228+
192229python3 -c "
193230import json, os, sys
194231
195- settings_path = os.path.expanduser('~/.claude/settings.json')
196- hook_cmd = os.path.expanduser('~/.claude/hooks/peon-ping/peon.sh')
232+ settings_path = ' $SETTINGS '
233+ hook_cmd = ' $HOOK_CMD '
197234
198235# Load existing settings
199236if os.path.exists(settings_path):
249286echo " "
250287echo " Testing sound..."
251288ACTIVE_PACK=$( python3 -c "
252- import json, os
289+ import json
253290try:
254- c = json.load(open(os.path.expanduser('~/.claude/hooks/peon-ping/ config.json') ))
291+ c = json.load(open(' $INSTALL_DIR / config.json'))
255292 print(c.get('active_pack', 'peon'))
256293except:
257294 print('peon')
298335echo " "
299336echo " Quick controls:"
300337echo " /peon-ping-toggle — toggle sounds in Claude Code"
301- echo " peon --toggle — toggle sounds from any terminal"
302- echo " peon --status — check if sounds are paused"
338+ if [ " $LOCAL_MODE " = false ]; then
339+ echo " peon --toggle — toggle sounds from any terminal"
340+ echo " peon --status — check if sounds are paused"
341+ fi
303342echo " "
304343echo " Ready to work!"
0 commit comments