Advertisement
Guest User

sh.lua

a guest
Nov 5th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. -- HouseShell
  2. -- As a part of HouseOS
  3.  
  4. -- Made by houseofkraft
  5.  
  6. -- Dependices
  7. fs = require("filesystem")
  8. os = require("os")
  9. shell = require("shell")
  10. event = require("event")
  11. term = require("term")
  12. shell = require("shell")
  13. gpu = term.gpu()
  14.  
  15. local motd = {
  16. "We hope you enjoy HouseOS!",
  17. "Have fun!",
  18. "Did you know, this is a customized Shell!",
  19. "Muhahahaahahah",
  20. "If you find any bugs, please tell House (houseofkraft)"
  21. }
  22.  
  23.  
  24.  
  25. -- Init
  26. --term.clear()
  27. --print("----- " .._OSVERSION.. " -----")
  28. --print(motd[math.random(1, #motd)])
  29.  
  30. function startProgramR()
  31.    shell.execute(cmd)
  32. end
  33.  
  34. function startProgram()
  35.    local ok, err = pcall(startProgram)
  36.    if err then
  37.      print("[ERROR]: "..err)
  38.    end
  39. end
  40.  
  41.  
  42. function loop()
  43.    gpu.setForeground(0xcc0202)
  44.    if shell.getWorkingDirectory() == "/"  then
  45.      -- Do nothing
  46.    else
  47.      io.write(shell.getWorkingDirectory())
  48.    end
  49.    gpu.setForeground(0xd7ea07)
  50.    io.write("/")
  51.    gpu.setForeground(0x03ba55)
  52.    io.write("# ")
  53.    gpu.setForeground(0xffffff)
  54.    cmd = io.read()
  55.    if fs.exists(cmd) == false then
  56.      if fs.exists("/bin/"..cmd..".lua") then
  57.        startProgram("/bin/" ..cmd.. ".lua")
  58.      elseif fs.exists("/lib/"..cmd..".lua") then
  59.        startProgram("/lib/"..cmd.. ".lua")
  60.      else
  61.        print("The program does not exist!")
  62.      end
  63.    else
  64.      startProgram(cmd)
  65.    end
  66.    loop()
  67. end
  68.  
  69. term.clear()
  70. --term.setCursorPos(1,1)
  71. print("------ ".._OSVERSION.." ------")
  72. print(motd[math.random(1, #motd)])
  73. loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement