Local MCP Server
在Termux中运行本地MCP服务器,支持Ollama模型的文件读取与命令执行。
下载 312
跨平台终端快捷指令,支持代理切换、路径跳转和GPU状态查看。
openclaw skills install @wangyendt/shell-shortcuts命令、参数、文件名以原文为准
目标:让一台新机器在 Windows / macOS / Ubuntu 系统上通过少量命令实现一致的行为:
proxy_on / proxy_off:切换终端代理(环境变量 + Git 全局代理)goto:持久化路径快捷方式(例如 goto work)gpu:显示 NVIDIA GPU 状态(nvidia-smi 封装;仅限 Windows/Ubuntu)此技能设计为有明确偏好:
goto 功能体验。http://127.0.0.1:7890socks5://127.0.0.1:7890localhost,127.0.0.1,.qualcomm.com,*.amazonaws.com编辑 PowerShell 配置文件:$PROFILE
添加(或替换)如下代码块。goto 的数据库路径为 $HOME\.goto_paths.json。
# >>> shell-shortcuts >>>
function proxy_off {
param([switch]$Quiet)
Remove-Item Env:http_proxy,Env:https_proxy,Env:all_proxy,Env:no_proxy -ErrorAction SilentlyContinue
Remove-Item Env:HTTP_PROXY,Env:HTTPS_PROXY,Env:ALL_PROXY,Env:NO_PROXY -ErrorAction SilentlyContinue
if (Get-Command git -ErrorAction SilentlyContinue) {
git config --global --unset http.proxy 2>$null | Out-Null
git config --global --unset https.proxy 2>$null | Out-Null
}
if (-not $Quiet) { Write-Host "代理已关闭" }
}
function proxy_on {
param(
[string]$HttpProxyUrl = "http://127.0.0.1:7890",
[string]$SocksProxyUrl = "socks5://127.0.0.1:7890",
[string]$NoProxyList = "localhost,127.0.0.1,.qualcomm.com,*.amazonaws.com"
)
proxy_off -Quiet
$env:http_proxy = $HttpProxyUrl
$env:https_proxy = $HttpProxyUrl
$env:HTTP_PROXY = $HttpProxyUrl
$env:HTTPS_PROXY = $HttpProxyUrl
$env:all_proxy = $SocksProxyUrl
$env:ALL_PROXY = $SocksProxyUrl
$env:no_proxy = $NoProxyList
$env:NO_PROXY = $NoProxyList
if (Get-Command git -ErrorAction SilentlyContinue) {
git config --global http.proxy $HttpProxyUrl | Out-Null
git config --global https.proxy $HttpProxyUrl | Out-Null
}
Write-Host "代理已开启"
Write-Host " HTTP/HTTPS: $HttpProxyUrl"
Write-Host " SOCKS5: $SocksProxyUrl"
Write-Host " NO_PROXY: $NoProxyList"
}
function _goto_db_path {
Join-Path $HOME ".goto_paths.json"
}
function _goto_load {
$db = _goto_db_path
if (-not (Test-Path -LiteralPath $db)) { return @{} }
try {
$raw = Get-Content -Raw -Encoding UTF8 -LiteralPath $db
if (-not $raw.Trim()) { return @{} }
$obj = $raw | ConvertFrom-Json
$ht = @{}
foreach ($p in $obj.PSObject.Properties) { $ht[$p.Name] = [string]$p.Value }
return $ht
} catch {
throw "无法解析 goto 数据库:$db。请修复 JSON 或删除该文件。"
}
}
function _goto_save([hashtable]$ht) {
$db = _goto_db_path
$dir = Split-Path -Parent $db
if (-not (Test-Path -LiteralPath $dir)) { New-Item -ItemType Directory -Path $dir | Out-Null }
($ht | ConvertTo-Json -Depth 5) | Set-Content -Encoding UTF8 -LiteralPath $db
}
function goto {
param(
[Parameter(Position = 0)][string]$Cmd,
[Parameter(ValueFromRemainingArguments = $true)][string[]]$Rest
)
$ht = _goto_load
switch ($Cmd) {
{ $_ -in @($null, "", "ls", "list") } {
if ($ht.Count -eq 0) { Write-Host "暂无快捷方式。使用:goto add <键名> <路径>"; return }
Write-Host "可用快捷方式:"
foreach ($k in ($ht.Keys | Sort-Object)) {
"{0,-12} -> {1}" -f $k, $ht[$k] | Write-Host
}
return
}
"add" {
if ($Rest.Count -lt 2) { throw "用法:goto add <快捷方式> <路径>" }
$key = $Rest[0]
$path = ($Rest | Select-Object -Skip 1) -join " "
if ($path -like "~*") { $path = $path -replace "^~", $HOME }
$resolved = Resolve-Path -LiteralPath $path -ErrorAction Stop
$ht[$key] = $resolved.Path
_goto_save $ht
Write-Host "已添加:$key -> $($ht[$key])"
return
}
{ $_ -in @("rm","remove","del") } {
if ($Rest.Count -ne 1) { throw "用法:goto remove <快捷方式>" }
$key = $Rest[0]
$ht.Remove($key) | Out-Null
_goto_save $ht
Write-Host "已移除:$key"
return
}
"clear" {
_goto_save @{}
Write-Host "所有快捷方式已清除。"
return
}
default {
if (-not $Cmd) { return }
if (-not $ht.ContainsKey($Cmd)) {
Write-Host "未知快捷方式:$Cmd"
Write-Host "提示:使用 goto list 查看可用项"
return 1
}
Set-Location -LiteralPath $ht[$Cmd]
return
}
}
}
function gpu {
$cmd = Get-Command nvidia-smi -ErrorAction SilentlyContinue
if (-not $cmd) {
Write-Host "未找到 nvidia-smi(需安装 NVIDIA 驱动或工具)。"
return 1
}
& $cmd.Path
}
# 可选:Conda 自动激活(请根据实际路径修改)
# $CondaRoot = "D:\\ProgramData\\miniconda3"
# $CondaEnv = "wayne3.10"
# if (Test-Path -LiteralPath (Join-Path $CondaRoot "Scripts\\conda.exe")) {
# $hook = (& (Join-Path $CondaRoot "Scripts\\conda.exe") "shell.powershell" "hook") 2>$null | Out-String
# if ($hook) { Invoke-Expression $hook }
# conda activate $CondaEnv
# }
# <<< shell-shortcuts <<<使用示例:
proxy_on
proxy_off
goto list
goto add work D:\work
goto work
gpuCMD 中 goto 是保留关键字。建议使用 jump 作为真实命令,并通过 doskey 为交互式会话设置别名 goto → jump。
推荐布局:
C:\Users\<你>\bin\创建文件 C:\Users\<你>\cmd_startup.cmd:
@echo off
set "PATH=%USERPROFILE%\bin;%PATH%"
REM 可选:Conda 自动激活(请根据实际路径修改)
REM call "D:\ProgramData\miniconda3\condabin\conda.bat" activate wayne3.10
REM 仅交互式会话有效(脚本或 /c 调用应直接调用 jump)
doskey goto=jump $*启用 AutoRun(当前用户):
reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun /t REG_SZ /d "%USERPROFILE%\cmd_startup.cmd" /f请在 %USERPROFILE%\bin 目录下创建以下 .cmd 文件:
proxy_on.cmd / proxy_off.cmd:设置或取消代理环境变量,并配置或取消 Git 的全局代理。gpu.cmd:执行 nvidia-smi 命令。jump.cmd:在 %USERPROFILE%\.goto_paths 中维护持久化的快捷路径数据库(格式:key|C:\abs\path)。如需完整模板,请参考 shell-shortcuts/references/windows-cmd.md。
将以下函数添加到 ~/.zshrc 或 ~/.bashrc 文件中:
proxy_on / proxy_offgoto(持久化数据库位于 ~/.goto_paths)gpu(需安装 nvidia-smi)模板文件位于 shell-shortcuts/references/unix.md,可直接复制粘贴并根据实际代理配置调整默认值。
已收录 4 个 Skill