Created
May 10, 2026 03:43
-
-
Save erlend/f2e6e56323346e96124647915de7318a to your computer and use it in GitHub Desktop.
Hammerspoon init that installs SpoonInstall if needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local INSTALL_URL = "https://github.com/Hammerspoon/Spoons/raw/refs/heads/master/Spoons/SpoonInstall.spoon.zip" | |
| local spoons_dir = hs.configdir .. "/Spoons" | |
| local install_dir = spoons_dir .. "/SpoonInstall.spoon" | |
| local zip_file = install_dir .. ".zip" | |
| if hs.fs.attributes(install_dir) == nil then | |
| hs.fs.mkdir(spoons_dir) | |
| local unpack = hs.task.new("/usr/bin/unzip", function(exit_code, _stdout, stderr) | |
| if exit_code ~= 0 then | |
| hs.printf("[SpoonInstall] Unpack failed: %s", stderr) | |
| return | |
| end | |
| os.remove(zip_file) | |
| hs.printf("Reloading configuration") | |
| hs.reload() | |
| end, { "-o", zip_file, "-d", spoons_dir }) | |
| local download = hs.task.new("/usr/bin/curl", function(exit_code, _stdout, stderr) | |
| if exit_code ~= 0 then | |
| hs.printf("[SpoonInstall] Download failed: %s", stderr) | |
| return | |
| end | |
| unpack:start() | |
| end, { "-Lfo", zip_file, INSTALL_URL }) | |
| if hs.fs.attributes(zip_file) then | |
| unpack:start() | |
| unpack:waitUntilExit() | |
| else | |
| download:start() | |
| download:waitUntilExit() | |
| end | |
| end | |
| hs.loadSpoon("SpoonInstall") | |
| -- SpoonInstall is now loaded. Add your configuration here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment