powershell-windows by comol/cursor_rules_1c
npx skills add https://github.com/comol/cursor_rules_1c --skill powershell-windows在 Windows 上正确使用 PowerShell 的基本规则。遵循这些规则以避免执行 shell 命令时的常见错误。
cd "path" && command (bash 语法)cd "path"; command (PowerShell 语法)对于包含空格的路径,始终使用双引号 :
cd "D:\My Projects\MyApp"
对于 .bat/.cmd 文件:
./gradlew clean build
.\gradlew.bat clean build
指定 docker-compose 文件的完整路径:
docker-compose -f "D:\My Projects\app\docker-compose.yml" up -d
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
错误 : curl -s http://localhost:9090/status
正确 :
Invoke-WebRequest -Uri "http://localhost:9090/status" -UseBasicParsing
错误 : timeout 10
正确 :
Start-Sleep -Seconds 10
JSON 解析:
$response = Invoke-WebRequest -Uri "http://localhost:9090/status" -UseBasicParsing
$json = $response.Content | ConvertFrom-Json
$json | ConvertTo-Json -Depth 3
进程搜索:
Get-Process -Name "java" -ErrorAction SilentlyContinue
停止容器:
docker-compose -f "path\to\file.yml" down
构建镜像:
docker-compose -f "path\to\file.yml" build --no-cache
忽略错误:
Get-Process -Name "java" -ErrorAction SilentlyContinue
| 错误 | 原因 | 修复 |
|---|---|---|
&& 无法识别 | 使用了 bash 语法 | 将 && 替换为 ; |
找不到 curl | Windows 上未安装 curl | 使用 Invoke-WebRequest |
找不到 timeout | 不支持 timeout | 使用 Start-Sleep |
找不到路径 | 包含空格的路径缺少引号 | 用双引号包裹路径 |
# 更改目录并执行命令
cd "D:\My Projects\MyApp"; ./gradlew clean build -x test
# 等待并发送 HTTP 请求
Start-Sleep -Seconds 10; Invoke-WebRequest -Uri "http://localhost:9090/status" -UseBasicParsing
# Docker 操作
docker-compose -f "D:\My Projects\MyApp\docker-compose.yml" down
docker-compose -f "D:\My Projects\MyApp\docker-compose.yml" build --no-cache
docker-compose -f "D:\My Projects\MyApp\docker-compose.yml" up -d
# 检查服务器状态
$response = Invoke-WebRequest -Uri "http://localhost:9090/status" -UseBasicParsing
$json = $response.Content | ConvertFrom-Json
Write-Host "Transport: $($json.mcp.transport)"
这些规则对于在 Windows PowerShell 环境中正常运行至关重要。
每周安装数
1
代码仓库
GitHub 星标数
176
首次出现
1 天前
安全审计
安装于
amp1
cline1
pi1
opencode1
cursor1
kimi-cli1
Essential rules for correct PowerShell usage on Windows. Follow these rules to avoid common errors when executing shell commands.
cd "path" && command (bash syntax)cd "path"; command (PowerShell syntax)Always use double quotes for paths with spaces:
cd "D:\My Projects\MyApp"
For .bat/.cmd files:
./gradlew clean build
.\gradlew.bat clean build
Specify full path to docker-compose files:
docker-compose -f "D:\My Projects\app\docker-compose.yml" up -d
Wrong : curl -s http://localhost:9090/status
Correct :
Invoke-WebRequest -Uri "http://localhost:9090/status" -UseBasicParsing
Wrong : timeout 10
Correct :
Start-Sleep -Seconds 10
JSON parsing:
$response = Invoke-WebRequest -Uri "http://localhost:9090/status" -UseBasicParsing
$json = $response.Content | ConvertFrom-Json
$json | ConvertTo-Json -Depth 3
Process search:
Get-Process -Name "java" -ErrorAction SilentlyContinue
Stop containers:
docker-compose -f "path\to\file.yml" down
Build images:
docker-compose -f "path\to\file.yml" build --no-cache
Ignore errors:
Get-Process -Name "java" -ErrorAction SilentlyContinue
| Error | Cause | Fix |
|---|---|---|
&& is not recognized | Using bash syntax | Replace && with ; |
curl not found | curl not installed on Windows | Use Invoke-WebRequest |
timeout not found | timeout not supported | Use Start-Sleep |
# Change directory and execute command
cd "D:\My Projects\MyApp"; ./gradlew clean build -x test
# Wait and make HTTP request
Start-Sleep -Seconds 10; Invoke-WebRequest -Uri "http://localhost:9090/status" -UseBasicParsing
# Docker operations
docker-compose -f "D:\My Projects\MyApp\docker-compose.yml" down
docker-compose -f "D:\My Projects\MyApp\docker-compose.yml" build --no-cache
docker-compose -f "D:\My Projects\MyApp\docker-compose.yml" up -d
# Check server status
$response = Invoke-WebRequest -Uri "http://localhost:9090/status" -UseBasicParsing
$json = $response.Content | ConvertFrom-Json
Write-Host "Transport: $($json.mcp.transport)"
These rules are critically important for proper operation in Windows PowerShell environment.
Weekly Installs
1
Repository
GitHub Stars
176
First Seen
1 day ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
amp1
cline1
pi1
opencode1
cursor1
kimi-cli1
Path not found | Missing quotes on spaced path | Wrap path in double quotes |