Files
karuo-ai/01_卡资(金)/金仓_存储备份/脚本/cursor_rg_check.sh
2026-07-19 00:21:46 +08:00

39 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# 自检 Cursor rg 风暴 · 期望 rg 02
# 用法: cursor_rg_check.sh [--fix]
# --fix: 仅 pkill 多余 rg不要求 Reload见 Cursor配置生效与Reload规则.md
set -euo pipefail
count_rg() {
local n=0
while IFS= read -r _; do ((n++)) || true; done < <(pgrep -lf '@vscode/ripgrep/bin/rg' 2>/dev/null || true)
echo "$n"
}
n=$(count_rg)
echo "Cursor rg 进程数: $n (期望 0-2)"
uptime | sed 's/.*load averages:/负载:/'
do_fix=false
[[ "${1:-}" == "--fix" ]] && do_fix=true
if [[ "$n" -gt 4 ]]; then
if $do_fix; then
echo ">> --fix: 结束多余 rg不 Reload..."
pkill -9 -f '@vscode/ripgrep/bin/rg' 2>/dev/null || true
sleep 2
n=$(count_rg)
echo ">> 修复后 rg 进程数: $n"
fi
fi
if [[ "$n" -gt 4 ]]; then
echo "⚠️ 仍偏多:请确认仅打开 personal.code-workspace2 根),勿开 个人_7根备份"
echo " 可先: bash \"$0\" --fix"
echo " 仅当刚改 .code-workspace 的 folders 时,收工后「打开工作区」一次;开发中勿 Reload"
exit 1
fi
echo "OK: 无需 Reload改 ignore/settings 保存即生效。"
exit 0