🔆
I have several Lua scripts I use a lot when working with larger projects. For a long time I simply copied them to a new folder whenever I started a new project.
This works fine, however, I end up with many versions of the same file, and copying and keeping them in sync is a hassle. It doesn’t have to be that way.
I decided to use ~/Software/lua
as my library of scripts. You can configure LUA_PATH
to point to additional directories where it can look for more programs. You just need to add this line to your shell configuration:
export LUA_PATH=";;$HOME/Software/lua/?.lua"
Lua replaces the double semicolon ;;
with the paths that it uses to search for scripts by default. The question mark ?
gets replaced with the argument you provide to require
.
Now I can just maintain a central directory where all my Lua scripts live. Neat.