Installation
Learn how to setup Hammerspoon and write your first config file.
Next ChapterSetting up the Hammerspoon program is actually pretty simple! All we need is to download it, create your config file, and open the program.
Installing Hammerspoon #
There are two ways to install the program.
Via homebrew #
If you already have Homebrew setup on your computer, just run:

brew install --cask hammerspoon
This will download Hammerspoon and install it to /Applications/Hammerspoon.app
.
Manually #
- Visit the Hammerspoon homepage.
- Click the Download link at the top.
- This will redirect you to the Github releases page.
- From there, download the
.zip
file (usually calledHammerspoon-<version number>.zip
. - Unzip it, and drag
Hammerspoon.app
to your/Applications
folder.
Your first config #
Now that you have Hammerspoon installed, all you need is a config file. Open your Terminal and paste in:

cat << EOF > ~/.hammerspoon/init.lua
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "w", function()
hs.alert.show("Hello World!")
end)
EOF
This will create a file at ~/.hammerspoon/init.lua
containing your first couple lines of Lua! You’ve made your first keybinding, which will pop up a Hello World! message.
Run it for the first time #
- Double click
Hammerspoon.app
inside your/Applications
folder. - It might ask you for some accessibility permissions the first time it runs. You’ll want to give these permissions by following the prompt.
- Press ⌘⌥⌃W. You should see Hello World! printed on the screen!
Hammerspoon is now setup and ready for you to add your own fun config too!
Initial tips
Optional tip: add your Hammerspoon config to Git #
If you track your dotfiles in version control, I recommend adding the entire ~/.hammerspoon
folder to your repository.
I have a ~/.dotfiles/hammerspoon
directory in my dotfiles repo. My dotfiles setup script takes care of creating a symlink:

ln -s ~/.dotfiles/hammerspoon ~/.hammerspoon
Once you do that, you can track any changes to your Hammerspoon config with the version control software of your choice. I highly recommend taking 5 minutes to do this now, before you get too deep in this course!