LolzPB

bash

May 21st, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. --Bash by Zeus
  2.  
  3. os.loadAPI("/lib/text/textlib")
  4.  
  5.  
  6. pathfile = fs.open("/etc/environment", "r")
  7. pathstr = pathfile.readAll()
  8. pathfile.close()
  9.  
  10. path = string.gsub(pathstr, "PATH=", "")
  11. path = string.gsub(path, "\"", "")
  12. paths = textlib.split(":", path)
  13.  
  14. while true do
  15. userfile = fs.open("/etc/user", "r")
  16. cUser = userfile.readAll()
  17. userfile.close()
  18. hostfile = fs.open("/etc/hostname", "r")
  19. hostname = hostfile.readAll()
  20. hostfile.close()
  21. term.setTextColor(colors.lime)
  22. term.write(cUser)
  23. term.write("@")
  24. term.write(hostname)
  25. term.setTextColor(colors.white)
  26. term.write(":")
  27. term.setTextColor(colors.blue)
  28. if shell.dir() == "home/"..cUser then
  29. term.write("~ ")
  30. else
  31. term.write("/"..shell.dir().." ")
  32. end
  33. term.setTextColor(colors.blue)
  34. term.write("$ ")
  35. term.setTextColor(colors.white)
  36. inp = read()
  37. cmd = textlib.split(" ", inp)
  38. trovato = false
  39. if string.sub(inp, 1, 2) == "./" then
  40. for i=0, #inp do
  41. if i == 1 and inp[i] == "." then
  42. inp[i] = ""
  43. end
  44. if i == 2 and inp[i] == "/" then
  45. inp[i] = ""
  46. end
  47. end
  48. cmd = textlib.split(" ", inp)
  49. cmd[1] = shell.resolve(cmd[1])
  50. if shell.run(unpack(cmd)) then
  51. trovato = true
  52. end
  53. end
  54.  
  55. for i, k in pairs(paths) do
  56. if fs.exists(k.."/"..cmd[1]) then
  57. tabcmd = {}
  58. inp = k.."/"..inp
  59. cmd = textlib.split(" ", inp)
  60. for i, k in pairs(cmd) do
  61. table.insert(tabcmd, k)
  62. end
  63. shell.run(unpack(tabcmd))
  64. trovato = true
  65. end
  66. end
  67. if not trovato then
  68. print("Programma non trovato")
  69. end
  70. end
Advertisement
Add Comment
Please, Sign In to add comment