Used as scripting language inside various tools like:
- Hammerspoon - system event handler for macOS
- MPV - video player
LuaCheck is the standard linter.
Install it on macOS using Homebrew:
brew install luacheckRun it against a lua script:
luacheck "$filename.lua"Output:
Checking resume-conditions.lua OK
Total: 0 warnings / 0 errors in 1 file
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.
In CI/CD I use a ready-to-run GitHub Actions reusable workflow from
HariSekhon/GitHub-Actions:
jobs:
LuaCheck:
name: LuaCheck
uses: HariSekhon/GitHub-Actions/.github/workflows/luacheck.yaml@masterHere is some real world Lua code for you as examples of how I've used this language.
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:
More details are in the Mac page's sections:
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.
HariSekhon/DevOps-Bash-tools - configs/.config/mpv/scripts/resume-conditions.lua