Posted 24 May 2014 - 02:29 AM
I'm making an OS which needs both a graphical shell and a command line shell. I'm going to handle graphical, but does anyone know of a good simple shell? I seem to be terrible at this stuff…
(
) See if you can fix that :P/>
(
Spoiler
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.clear()
term.setCursorPos(1, 1)
shellVars = {}
shellVars.PS1 = "$ "
shellVars.PS1Color = {
['bg'] = colors.black,
['fg'] = colors.yellow,
}
local accepting = true
while accepting do
term.setBackgroundColor(shellVars.PS1Color.bg)
term.setTextColor(shellVars.PS1Color.fg)
write(shellVars.PS1)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
local inputCMD = read()
if inputCMD == "exit" then
accepting = false
elseif inputCMD == "help" then
print(" ")
print("CWCOS sh version 1")
print("Built-in commands:")
print("exit - exits")
print("help - shows this help")
else
local split = string.gmatch(inputCMD, "%S+")
local cmd = split[0]
print("Split:")
print(textutils.serialize(split))
print("CMD:")
print(cmd)
sleep(5)
table.remove(split, 0)
if split[0] then
os.run({}, cmd, split)
else
os.run({}, cmd)
end
end
end