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"
24+ PACKS=" acolyte_ru glados peon peon_fr peon_pl peon_ru peasant peasant_fr peasant_ru ra2_soviet_engineer sc_battlecruiser sc_firebat sc_kerrigan sc_medic sc_scv sc_tank sc_terran sc_vessel tf2_engineer "
1325
1426# --- Platform detection ---
1527detect_platform () {
@@ -87,8 +99,12 @@ elif [ "$PLATFORM" = "linux" ]; then
8799 fi
88100fi
89101
90- if [ ! -d " $HOME /.claude" ]; then
91- echo " Error: ~/.claude/ not found. Is Claude Code installed?"
102+ if [ ! -d " $BASE_DIR " ]; then
103+ if [ " $LOCAL_MODE " = true ]; then
104+ echo " Error: .claude/ not found in current directory. Is this a Claude Code project?"
105+ else
106+ echo " Error: ~/.claude/ not found. Is Claude Code installed?"
107+ fi
92108 exit 1
93109fi
94110
152168chmod +x " $INSTALL_DIR /peon.sh"
153169
154170# --- Install skill (slash command) ---
155- SKILL_DIR=" $HOME /.claude /skills/peon-ping-toggle"
171+ SKILL_DIR=" $BASE_DIR /skills/peon-ping-toggle"
156172mkdir -p " $SKILL_DIR "
173+ if [ " $LOCAL_MODE " = true ]; then
174+ SKILL_HOOK_CMD=" bash .claude/hooks/peon-ping/peon.sh"
175+ else
176+ SKILL_HOOK_CMD=" bash ~/.claude/hooks/peon-ping/peon.sh"
177+ fi
157178if [ -n " $SCRIPT_DIR " ] && [ -d " $SCRIPT_DIR /skills/peon-ping-toggle" ]; then
158179 cp " $SCRIPT_DIR /skills/peon-ping-toggle/SKILL.md" " $SKILL_DIR /"
180+ if [ " $LOCAL_MODE " = true ]; then
181+ sed -i.bak ' s|bash ~/.claude/hooks/peon-ping/peon.sh|' " $SKILL_HOOK_CMD " ' |g' " $SKILL_DIR /SKILL.md"
182+ rm -f " $SKILL_DIR /SKILL.md.bak"
183+ fi
159184elif [ -z " $SCRIPT_DIR " ]; then
160185 curl -fsSL " $REPO_BASE /skills/peon-ping-toggle/SKILL.md" -o " $SKILL_DIR /SKILL.md"
186+ if [ " $LOCAL_MODE " = true ]; then
187+ sed -i.bak ' s|bash ~/.claude/hooks/peon-ping/peon.sh|' " $SKILL_HOOK_CMD " ' |g' " $SKILL_DIR /SKILL.md"
188+ rm -f " $SKILL_DIR /SKILL.md.bak"
189+ fi
161190else
162191 echo " Warning: skills/peon-ping-toggle not found in local clone, skipping skill install"
163192fi
164193
165- # --- Add shell alias ---
166- ALIAS_LINE=' alias peon="bash ~/.claude/hooks/peon-ping/peon.sh"'
167- for rcfile in " $HOME /.zshrc" " $HOME /.bashrc" ; do
168- if [ -f " $rcfile " ] && ! grep -qF ' alias peon=' " $rcfile " ; then
169- echo " " >> " $rcfile "
170- echo " # peon-ping quick controls" >> " $rcfile "
171- echo " $ALIAS_LINE " >> " $rcfile "
172- echo " Added peon alias to $( basename " $rcfile " ) "
173- fi
174- done
194+ # --- Add shell alias (global install only) ---
195+ if [ " $LOCAL_MODE " = false ]; then
196+ ALIAS_LINE=' alias peon="bash ~/.claude/hooks/peon-ping/peon.sh"'
197+ for rcfile in " $HOME /.zshrc" " $HOME /.bashrc" ; do
198+ if [ -f " $rcfile " ] && ! grep -qF ' alias peon=' " $rcfile " ; then
199+ echo " " >> " $rcfile "
200+ echo " # peon-ping quick controls" >> " $rcfile "
201+ echo " $ALIAS_LINE " >> " $rcfile "
202+ echo " Added peon alias to $( basename " $rcfile " ) "
203+ fi
204+ done
175205
176- # --- Add tab completion ---
177- COMPLETION_LINE=' [ -f ~/.claude/hooks/peon-ping/completions.bash ] && source ~/.claude/hooks/peon-ping/completions.bash'
178- for rcfile in " $HOME /.zshrc" " $HOME /.bashrc" ; do
179- if [ -f " $rcfile " ] && ! grep -qF ' peon-ping/completions.bash' " $rcfile " ; then
180- echo " $COMPLETION_LINE " >> " $rcfile "
181- echo " Added tab completion to $( basename " $rcfile " ) "
182- fi
183- done
206+ # --- Add tab completion ---
207+ COMPLETION_LINE=' [ -f ~/.claude/hooks/peon-ping/completions.bash ] && source ~/.claude/hooks/peon-ping/completions.bash'
208+ for rcfile in " $HOME /.zshrc" " $HOME /.bashrc" ; do
209+ if [ -f " $rcfile " ] && ! grep -qF ' peon-ping/completions.bash' " $rcfile " ; then
210+ echo " $COMPLETION_LINE " >> " $rcfile "
211+ echo " Added tab completion to $( basename " $rcfile " ) "
212+ fi
213+ done
214+ fi
184215
185216# --- Verify sounds are installed ---
186217echo " "
@@ -194,8 +225,8 @@ for pack in $PACKS; do
194225 fi
195226done
196227
197- # --- Backup existing notify.sh (fresh install only) ---
198- if [ " $UPDATING " = false ]; then
228+ # --- Backup existing notify.sh (global fresh install only) ---
229+ if [ " $LOCAL_MODE " = false ] && [ " $ UPDATING" = false ]; then
199230 NOTIFY_SH=" $HOME /.claude/hooks/notify.sh"
200231 if [ -f " $NOTIFY_SH " ]; then
201232 cp " $NOTIFY_SH " " $NOTIFY_SH .backup"
208239echo " "
209240echo " Updating Claude Code hooks in settings.json..."
210241
242+ if [ " $LOCAL_MODE " = true ]; then
243+ HOOK_CMD=" .claude/hooks/peon-ping/peon.sh"
244+ else
245+ HOOK_CMD=" $HOME /.claude/hooks/peon-ping/peon.sh"
246+ fi
247+
211248python3 -c "
212249import json, os, sys
213250
214- settings_path = os.path.expanduser('~/.claude/settings.json')
215- hook_cmd = os.path.expanduser('~/.claude/hooks/peon-ping/peon.sh')
251+ settings_path = ' $SETTINGS '
252+ hook_cmd = ' $HOOK_CMD '
216253
217254# Load existing settings
218255if os.path.exists(settings_path):
268305echo " "
269306echo " Testing sound..."
270307ACTIVE_PACK=$( python3 -c "
271- import json, os
308+ import json
272309try:
273- c = json.load(open(os.path.expanduser('~/.claude/hooks/peon-ping/ config.json') ))
310+ c = json.load(open(' $INSTALL_DIR / config.json'))
274311 print(c.get('active_pack', 'peon'))
275312except:
276313 print('peon')
329366echo " "
330367echo " Quick controls:"
331368echo " /peon-ping-toggle — toggle sounds in Claude Code"
332- echo " peon --toggle — toggle sounds from any terminal"
333- echo " peon --status — check if sounds are paused"
369+ if [ " $LOCAL_MODE " = false ]; then
370+ echo " peon --toggle — toggle sounds from any terminal"
371+ echo " peon --status — check if sounds are paused"
372+ fi
334373echo " "
335374echo " Ready to work!"
0 commit comments