-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·59 lines (53 loc) · 2.41 KB
/
Copy pathuninstall.sh
File metadata and controls
executable file
·59 lines (53 loc) · 2.41 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
#!/usr/bin/env bash
# Uninstaller for cc-usage-statusline. Removes our scripts and our statusLine
# entry + SessionStart hook from settings.json, plus any leftovers from older
# (OAuth-fetch) versions. Leaves the rest of your settings alone.
set -euo pipefail
CLAUDE_DIR="$HOME/.claude"
TARGET="$CLAUDE_DIR/statusline.sh"
SETTINGS="$CLAUDE_DIR/settings.json"
LABEL="com.cc-usage-statusline.refresh"
# Stop + remove any background refresher shipped by older versions.
case "$(uname -s 2>/dev/null)" in
Darwin)
PLIST="$HOME/Library/LaunchAgents/$LABEL.plist"
if [ -e "$PLIST" ]; then
launchctl bootout "gui/$(id -u)/$LABEL" 2>/dev/null \
|| launchctl unload "$PLIST" 2>/dev/null || true
rm -f "$PLIST"
echo "✓ removed old launchd refresher"
fi ;;
Linux)
if command -v systemctl >/dev/null 2>&1; then
systemctl --user disable --now cc-usage-refresh.timer 2>/dev/null || true
rm -f "$HOME/.config/systemd/user/cc-usage-refresh.timer" \
"$HOME/.config/systemd/user/cc-usage-refresh.service"
systemctl --user daemon-reload 2>/dev/null || true
fi
if command -v crontab >/dev/null 2>&1; then
crontab -l 2>/dev/null | grep -vF "usage-refresh.sh" | crontab - 2>/dev/null || true
fi ;;
MINGW*|MSYS*|CYGWIN*)
command -v schtasks >/dev/null 2>&1 && schtasks //Delete //F //TN "$LABEL" >/dev/null 2>&1 || true ;;
esac
rm -f "$TARGET" "$CLAUDE_DIR/platform.sh" \
"$CLAUDE_DIR/usage-fetch.sh" "$CLAUDE_DIR/usage-refresh.sh" \
"$CLAUDE_DIR/commands/usage-refresh.md" \
"$CLAUDE_DIR/.usage-cache.json" "$CLAUDE_DIR/.usage-cache.lock" \
"$CLAUDE_DIR/.usage-cache.attempt" "$CLAUDE_DIR/.usage-cache.backoff"
echo "✓ removed $TARGET and support files"
if [ -s "$SETTINGS" ]; then
tmp=$(mktemp)
jq --arg cmd "$TARGET" '
(.statusLine = (if .statusLine.command == $cmd then null else .statusLine end))
| (.hooks.SessionStart = (
(.hooks.SessionStart // [])
| map(select((.hooks // []) | any(.command // "" | contains("tengu_c4w_usage_limit_notifications_enabled")) | not))
))
| (if (.hooks.SessionStart // []) == [] then del(.hooks.SessionStart) else . end)
| (if (.hooks // {}) == {} then del(.hooks) else . end)
| (if .statusLine == null then del(.statusLine) else . end)
' "$SETTINGS" > "$tmp" && mv "$tmp" "$SETTINGS"
echo "✓ cleaned $SETTINGS"
fi
echo "done. Restart Claude Code to drop the status line."