helm/hammerspoon/util.lua

35 lines
749 B
Lua
Raw Normal View History

2015-12-25 03:43:34 -08:00
2015-12-26 23:29:38 -08:00
return {
2015-12-25 03:43:34 -08:00
apps = {},
bindings = {},
ls = function(directory)
local i, t, popen = 0, {}, io.popen
for filename in popen('ls -a "'..directory..'"'):lines() do
i = i + 1
t[i] = filename
end
return t
end,
reload = function()
hs.reload()
hs.alert("Config reloaded!")
end,
call = function(obj, fn)
return function () return obj[fn](obj) end
end,
autoimport = function(dir)
for _, file in pairs(util.ls(dir)) do
if file:find(".+%.lua") then
local a = string.gsub(file, '%.lua', '')
print(a .. " loaded")
require(dir .. "/" .. a)
end
end
end
}