1
0
mirror of https://github.com/kepler155c/opus synced 2024-06-15 01:39:59 +00:00

better startup

This commit is contained in:
kepler155c@gmail.com 2017-09-26 05:34:31 -04:00
parent 2d93974e6a
commit f2e1a39584
3 changed files with 28 additions and 29 deletions

View File

@ -52,23 +52,10 @@ local config = {
tabBarBackgroundColor = colors.gray, tabBarBackgroundColor = colors.gray,
focusBackgroundColor = colors.gray, focusBackgroundColor = colors.gray,
}, },
-- path = '.:/apps:' .. shell.path():sub(3),
path = shell.path(),
} }
Config.load('multishell', config) Config.load('multishell', config)
shell.setPath(config.path)
if config.aliases then
for k in pairs(shell.aliases()) do
shell.clearAlias(k)
end
for k,v in pairs(config.aliases) do
shell.setAlias(k, v)
end
end
local _colors = config.standard local _colors = config.standard
if parentTerm.isColor() then if parentTerm.isColor() then
_colors = config.color _colors = config.color

View File

@ -236,7 +236,7 @@ if #tArgs > 0 then
-- "shell x y z" -- "shell x y z"
-- Run the program specified in this new shell -- Run the program specified in this new shell
local s, m = shell.run( ... ) local s, m = shell.run( ... )
if not s and m ~= 'Terminated' then if not s and m and m ~= 'Terminated' then
error(m or '') error(m or '')
end end
return s, m return s, m

View File

@ -33,9 +33,7 @@ local GIT_REPO = 'kepler155c/opus/develop'
local BASE = 'https://raw.githubusercontent.com/' .. GIT_REPO local BASE = 'https://raw.githubusercontent.com/' .. GIT_REPO
local function makeEnv() local function makeEnv()
local env = setmetatable({ local env = setmetatable({ }, { __index = _G })
LUA_PATH = '/sys/apis:/usr/apis'
}, { __index = _G })
for k,v in pairs(getfenv(1)) do for k,v in pairs(getfenv(1)) do
env[k] = v env[k] = v
end end
@ -52,11 +50,8 @@ local function run(file, ...)
end) end)
end end
if not s then if not s and m then
-- term.setBackgroundColor(colors.black) error('Error loading ' .. file .. '\n' .. m)
-- term.clear()
printError('Error loading ' .. file)
error(m)
end end
return m return m
end end
@ -72,13 +67,10 @@ local function runUrl(file, ...)
return fn(...) return fn(...)
end end
end end
-- term.setBackgroundColor(colors.black)
-- term.clear()
error('Failed to download ' .. url) error('Failed to download ' .. url)
end end
shell.setPath('usr/apps:sys/apps:' .. shell.path()) -- Install require shim
if fs.exists('sys/apis/injector.lua') then if fs.exists('sys/apis/injector.lua') then
_G.requireInjector = run('sys/apis/injector.lua') _G.requireInjector = run('sys/apis/injector.lua')
else else
@ -90,6 +82,8 @@ else
fs.mount('', 'gitfs', GIT_REPO) fs.mount('', 'gitfs', GIT_REPO)
end end
local Util = run('sys/apis/util.lua')
-- user environment -- user environment
if not fs.exists('usr/apps') then if not fs.exists('usr/apps') then
fs.makeDir('usr/apps') fs.makeDir('usr/apps')
@ -98,10 +92,28 @@ if not fs.exists('usr/autorun') then
fs.makeDir('usr/autorun') fs.makeDir('usr/autorun')
end end
if not fs.exists('usr/etc/fstab') then if not fs.exists('usr/etc/fstab') then
local file = io.open('usr/etc/fstab', "w") Util.writeFile('usr/etc/fstab', 'usr gitfs kepler155c/opus-apps/develop')
file:write('usr gitfs kepler155c/opus-apps/master')
file:close()
end end
if not fs.exists('usr/config/shell') then
Util.writeTable('usr/config/shell', {
aliases = shell.aliases(),
path = 'usr/apps:sys/apps:' .. shell.path(),
LUA_PATH = '/sys/apis:/usr/apis',
})
end
-- shell environment
local config = Util.readTable('usr/config/shell')
if config.aliases then
for k in pairs(shell.aliases()) do
shell.clearAlias(k)
end
for k,v in pairs(config.aliases) do
shell.setAlias(k, v)
end
end
shell.setPath(config.path)
LUA_PATH = config.LUA_PATH
-- extensions -- extensions
local dir = 'sys/extensions' local dir = 'sys/extensions'