diff --git a/CHANGELOG.md b/CHANGELOG.md index d775885..dd733c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,8 @@ having and using multiple runners. - .. and 2 properties - `fs.pathSep` is the separator for filesystem paths and directories - `fs.pathListSep` is the separator for $PATH env entries +- Lua modules located in `hilbish.userDir.data .. '/hilbish/start'` (like `~/.local/share/hilbish/start/foo/init.lua`) +will be ran on startup ### Changed - **Breaking Change:** Upgraded to Lua 5.4. diff --git a/nature/init.lua b/nature/init.lua index 8671087..df31d8d 100644 --- a/nature/init.lua +++ b/nature/init.lua @@ -1,5 +1,6 @@ -- Prelude initializes everything else for our shell local _ = require 'succulent' -- Function additions +local fs = require 'fs' package.path = package.path .. ';' .. hilbish.dataDir .. '/?/init.lua' .. ';' .. hilbish.dataDir .. '/?/?.lua' .. ";" .. hilbish.dataDir .. '/?.lua' @@ -45,3 +46,20 @@ do }) end +do + local startSearchPath = hilbish.userDir.data .. '/hilbish/start/?/init.lua;' + .. hilbish.userDir.data .. '/hilbish/start/?.lua' + + local ok, modules = pcall(fs.readdir, hilbish.userDir.data .. '/hilbish/start/') + if ok then + for _, module in ipairs(modules) do + local entry = package.searchpath(module, startSearchPath) + print(entry) + if entry then + dofile(entry) + end + end + end + + package.path = package.path .. ';' .. startSearchPath +end