Skip to content

Instantly share code, notes, and snippets.

@HariSekhon
Last active January 8, 2026 07:57
Show Gist options
  • Select an option

  • Save HariSekhon/5d92962d87de0d6da77024fc2ddc37fd to your computer and use it in GitHub Desktop.

Select an option

Save HariSekhon/5d92962d87de0d6da77024fc2ddc37fd to your computer and use it in GitHub Desktop.
lua.md from HariSekhon/Knowledge-Base repo: https://github.com/HariSekhon/Knowledge-Base

Lua

Summary

Used as scripting language inside various tools like:

Linting

LuaCheck

LuaCheck is the standard linter.

Install it on macOS using Homebrew:

brew install luacheck

Run it against a lua script:

luacheck "$filename.lua"

Output:

Checking resume-conditions.lua                    OK

Total: 0 warnings / 0 errors in 1 file

LuaCheck HotKey Integration

I call this locally via a hotkey in my .vimrc and IntelliJ which both call my generalized lint.sh script provided in DevOps-Bash-tools which is in my $PATH.

DevOps-Bash-tools

LuaCheck CI/CD

In CI/CD I use a ready-to-run GitHub Actions reusable workflow from :octocat: HariSekhon/GitHub-Actions:

jobs:
  LuaCheck:
    name: LuaCheck
    uses: HariSekhon/GitHub-Actions/.github/workflows/luacheck.yaml@master

GitHub-Actions

Real World Lua Code

Here is some real world Lua code for you as examples of how I've used this language.

Hammerspoon Event Handler for macOS

I this code to automatically switch macOS sound when AirPods connect to a dual output channel so that I can Shazam songs from Love Island while watching it:

:octocat: HariSekhon/Hammerspoon

More details are in the Mac page's sections:

MPV video player

I use this code to automatically resume playing videos in mpv only if they match the conditions I want, such as videos have to be a certain length and I have to be more than a certain amount of time into the video otherwise you may as well start it from the beginning.

This is impressively flexible to suit your preferences.

:octocat: HariSekhon/DevOps-Bash-tools - configs/.config/mpv/scripts/resume-conditions.lua

More details are found in the Video page's MPV section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment