mbs-multishell/module.lua

by hugeblank
535 days ago
COPY
1
local function lib_load(path, name)
2
  if not _G[name] then
3
    os.loadAPI(fs.combine(path, "lib/" .. name .. ".lua"))
4
    if not _G[name] then _G[name] = _G[name .. ".lua"] end
5
  end
6
end
7

8
return {
9
  description = "Replaces multishell with an advanced version.",
10

11
  dependencies = {
12
    "bin/multishell.lua",
13
  },
14

15
  -- When updating the defaults, one should also update bin/shell.lua
16
  settings = {
17
    {
18
      name = "mbs.multishell.enabled",
19
      description = "Whether the extended multishell is enabled.",
20
      default = true,
21
      type = "boolean",
22
    },
23
    {
24
      name = "mbs.multishell.ctrl",
25
      description = "The keycode to use for the default ctrl action",
26
      default = keys.leftCtrl,
27
      type = "number",
28
    },
29
    {
30
      name = "mbs.multishell.tab",
31
      description = "The keycode to use for the default tab action",
32
      default = keys.tab,
33
      type = "number",
34
    },
35
    {
36
      name = "mbs.multishell.shift",
37
      description = "The keycode to use for the default shift action",
38
      default = keys.leftShift,
39
      type = "number",
40
    },
41
    {
42
      name = "mbs.multishell.restoreTab",
43
      description = "Whether the first forward tab action will skip to the last used window",
44
      default = true,
45
      type = "boolean",
46
    }
47
  },
48

49
  enabled = function() return settings.get("mbs.multishell.enabled") end,
50

51
  setup = function(path)
52
    if not multishell._mbs then
53
        shell.setAlias("multishell", "/" .. fs.combine(path, "bin/multishell.lua"))
54
        loadfile(fs.combine(path, "bin/multishell.lua"), _ENV)(shell.getRunningProgram())
55
    end
56
  end,
57
}