Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计提醒

hammerspoonhammerspoon 搜索

Agent Skill

hammerspoon 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

528

周安装

22

GitHub Stars

6

下载量

176
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:hammerspoon(hammerspoon 搜索)
来源仓库:https://github.com/plinde/claude-plugins
仓库路径:skills/hammerspoon
安装命令:
npx skills add https://github.com/plinde/claude-plugins --skill hammerspoon
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/plinde/claude-plugins --skill hammerspoon

简介

查询 Mac 上 Hammerspoon 自动化脚本的配置与使用案例。

  • 适用于系统级快捷键、窗口管理与 AppleScript 集成任务。
  • 提供 Lua 片段与 API 文档链接,供开发者参考。
  • 运行脚本可能影响系统稳定性,建议在沙盒环境测试。
  • hammerspoon 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Hammerspoon macOS Automation

Hammerspoon bridges macOS and Lua scripting for powerful desktop automation.

Directory Structure

~/.hammerspoon/
├── init.lua              # Main entry point (always loaded on startup)
├── Spoons/               # Plugin directory
│   └── *.spoon/          # Individual Spoon packages
│       └── init.lua      # Spoon entry point
└── .gitignore

Configuration Basics

init.lua - Entry Point

Hammerspoon always loads ~/.hammerspoon/init.lua on startup:

-- Enable CLI support (required for hs command)
require("hs.ipc")

-- Load a Spoon
hs.loadSpoon("SpoonName")

-- Configure the Spoon
spoon.SpoonName:bindHotkeys({...})

Loading Spoons

-- Load and auto-init (default)
hs.loadSpoon("MySpoon")

-- Load without global namespace
local mySpoon = hs.loadSpoon("MySpoon", false)

When loaded, Spoons are accessible via spoon.SpoonName.

CLI Usage (hs command)

Prerequisite: Add require("hs.ipc") to init.lua, then reload manually once.

# Reload configuration
hs -c 'hs.reload()'

# Show alert on screen
hs -c 'hs.alert("Hello from CLI")'

# Run any Lua code
hs -c 'print(hs.host.locale.current())'

# Get focused window info
hs -c 'print(hs.window.focusedWindow():title())'

Window Management with ShiftIt

ShiftIt is a popular Spoon for window tiling.

Installation

# Download from https://github.com/peterklijn/hammerspoon-shiftit
# Extract to ~/.hammerspoon/Spoons/ShiftIt.spoon/

Configuration

require("hs.ipc")
hs.loadSpoon("ShiftIt")

spoon.ShiftIt:bindHotkeys({
    -- Halves
    left = { { 'ctrl', 'cmd' }, 'left' },
    right = { { 'ctrl', 'cmd' }, 'right' },
    up = { { 'ctrl', 'cmd' }, 'up' },
    down = { { 'ctrl', 'cmd' }, 'down' },

    -- Quarters
    upleft = { { 'ctrl', 'cmd' }, '1' },
    upright = { { 'ctrl', 'cmd' }, '2' },
    botleft = { { 'ctrl', 'cmd' }, '3' },
    botright = { { 'ctrl', 'cmd' }, '4' },

    -- Other
    maximum = { { 'ctrl', 'cmd' }, 'm' },
    toggleFullScreen = { { 'ctrl', 'cmd' }, 'f' },
    center = { { 'ctrl', 'cmd' }, 'c' },
    nextScreen = { { 'ctrl', 'cmd' }, 'n' },
    previousScreen = { { 'ctrl', 'cmd' }, 'p' },
    resizeOut = { { 'ctrl', 'cmd' }, '=' },
    resizeIn = { { 'ctrl', 'cmd' }, '-' },
})

Modifier Keys

KeyLua Name
Command'cmd'
Control'ctrl'
Option/Alt'alt'
Shift'shift'

Hotkey Binding (Without Spoons)

-- Simple hotkey
hs.hotkey.bind({'cmd', 'alt'}, 'R', function()
    hs.reload()
end)

-- Hotkey with message
hs.hotkey.bind({'cmd', 'shift'}, 'H', function()
    hs.alert.show('Hello!')
end)

Common Modules

hs.window - Window Management

-- Get focused window
local win = hs.window.focusedWindow()

-- Move/resize
win:moveToUnit('[0,0,0.5,1]')  -- Left half
win:maximize()
win:centerOnScreen()

-- Get all windows
local allWindows = hs.window.allWindows()

hs.application - App Control

-- Launch or focus app
hs.application.launchOrFocus('Safari')

-- Get running app
local app = hs.application.get('Finder')
app:activate()

hs.alert - On-screen Messages

hs.alert.show('Message')
hs.alert.show('Message', nil, nil, 3)  -- 3 second duration

hs.notify - System Notifications

hs.notify.new({title='Title', informativeText='Body'}):send()

hs.caffeinate - Sleep/Wake

-- Prevent sleep
hs.caffeinate.set('displayIdle', true)

-- Watch for sleep/wake events
hs.caffeinate.watcher.new(function(event)
    if event == hs.caffeinate.watcher.systemWillSleep then
        print('Going to sleep')
    end
end):start()

Spoons

What is a Spoon?

Self-contained Lua plugin with standard structure:

MySpoon.spoon/
└── init.lua     # Required: exports a table with methods

Official Spoon Repository

SpoonInstall - Package Manager

hs.loadSpoon("SpoonInstall")

-- Install from official repo
spoon.SpoonInstall:andUse("ReloadConfiguration", {
    start = true
})

-- Install from custom repo
spoon.SpoonInstall.repos.Custom = {
    url = "https://github.com/user/repo",
    desc = "Custom spoons",
    branch = "main",
}
spoon.SpoonInstall:andUse("CustomSpoon", { repo = "Custom" })

Configuration Reloading

Manual Reload

  • Click menubar icon -> "Reload Config"
  • Or bind a hotkey:
hs.hotkey.bind({'cmd', 'alt', 'ctrl'}, 'R', function()
    hs.reload()
end)

Auto-reload on File Change

hs.loadSpoon("ReloadConfiguration")
spoon.ReloadConfiguration:start()

Or manually:

local configWatcher = hs.pathwatcher.new(os.getenv('HOME') .. '/.hammerspoon/', function(files)
    for _, file in pairs(files) do
        if file:sub(-4) == '.lua' then
            hs.reload()
            return
        end
    end
end):start()

CLI Reload

hs -c 'hs.reload()'

Note: Requires require("hs.ipc") in init.lua.

Troubleshooting

IPC Not Working

error: can't access Hammerspoon message port

Fix: Add require("hs.ipc") to init.lua and reload manually via menubar.

Spoon Not Loading

  1. Check path: ~/.hammerspoon/Spoons/Name.spoon/init.lua
  2. Check Lua syntax in Spoon's init.lua
  3. Check Hammerspoon console for errors (menubar -> Console)

Hotkey Not Working

  1. Check for conflicts with system shortcuts
  2. Verify modifier key names are lowercase strings
  3. Check console for binding errors

Console and Debugging

-- Print to console
print('Debug message')

-- Inspect objects
hs.inspect(someTable)

-- Open console
hs.openConsole()

Access console: Menubar icon -> Console (or Cmd+Alt+C if bound)

Best Practices

  1. Always use IPC - Add require("hs.ipc") for CLI support
  2. Use Spoons - Don't reinvent window management
  3. Version control - Track ~/.hammerspoon/ with git
  4. Capture variables - Objects not stored in variables get garbage collected
  5. Check console - First place to look for errors

References

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

openclaw

25.88%
按下载量换算46

Claude Code

24.87%
按下载量换算44

Gemini CLI

18.54%
按下载量换算33

windsurf

12.77%
按下载量换算22

trae

8.8%
按下载量换算15

trae-cn

3.58%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills