Advertisement
Agent_Silence

TitanShell

Jun 24th, 2014 (edited)
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.96 KB | None | 0 0
  1. -- Titan Shell
  2. -- by Agent Silence
  3. -- Please message me through the ComputerCraft forums if you have included this in any os!
  4.  
  5. OS = false
  6. OSname = "Put OS filename here"
  7. blacklist = {
  8. "Put your blacklisted commands here"
  9. }
  10.  
  11. functionsList = { -- Add your function
  12.         function() -- Prints all previously typed commands
  13.             if #prevTyped < 18 then
  14.                 for k, v in ipairs(prevTyped) do
  15.                         print(k..": "..v)      
  16.                 end
  17.             else
  18.                 textutils.pagedTabulate(prevTyped)
  19.             end
  20.         end,
  21.  
  22.         function() -- Clears previously typed commands
  23.                 term.clear()
  24.                 term.setCursorPos(1,1)
  25.                 for i=1,#prevTyped do
  26.                         table.remove(prevTyped)    
  27.                 end
  28.         end     ,
  29.  
  30.         function()
  31.             if OS == false then
  32.                 isOnShell = false
  33.                 term.setBackgroundColor(colors.black)
  34.                 term.clear()
  35.                 term.setCursorPos(1,1)
  36.                 print("Thank you for using Titan by Agent Silence")
  37.             else
  38.                 isOnShell = false
  39.                 term.clear()
  40.                 shell.run(OSname)
  41.             end
  42.         end,
  43.        
  44.         function()
  45.                 os.unloadAPI("setting")
  46.                 shell.run("shell")
  47.         end,
  48.        
  49.         function()
  50.                 shell.setDir("")
  51.         end
  52. }
  53.  
  54.  
  55. if fs.exists("setting") == false then
  56. local code = [[
  57. main = {
  58. ["Text Color"] = colors.lightGray,
  59. -- Text color of the console
  60.  
  61. ["Background Color"] = colors.black,
  62. -- Background color
  63.  
  64. ["CMD Count"] = true,
  65. -- Keep track of amount of commands typed
  66. }
  67.  
  68. ]]
  69.  
  70. local file = fs.open("setting", "w")
  71. file.write(code)
  72. file.close()
  73. end
  74.  
  75. os.loadAPI("setting")
  76. os.pullEvent = os.pullEventRaw
  77.  
  78. prevTyped = { } -- Previously called commands
  79. aliasList = { }
  80. aliasNum = { }
  81. isOnShell = true
  82.  
  83. function alias(nPath,alias) -- Calls an alias to a function
  84.         table.insert(aliasList, alias)
  85.         table.insert(aliasNum, nPath)
  86. end
  87.  
  88. term.clear()
  89. curX, curY = term.getCursorPos(1,1)
  90. term.setCursorPos(1,1)
  91.  
  92. -- Alias's Here --
  93. alias(1,"prev")
  94. alias(1,"previous")
  95. alias(2,"clear")
  96. alias(2,"empty")
  97. alias(2,"wipe")
  98. alias(3,"exit")
  99. alias(4,"reload")
  100. alias(4,"rld")
  101. alias(5,"back")
  102. alias(5,"main")
  103. ------------------
  104.  
  105. while isOnShell do
  106.  
  107.         term.setBackgroundColor(setting.main["Background Color"])
  108.         term.setTextColor(colors.green)
  109.        
  110.         if setting.main["CMD Count"] == false then
  111.                 term.write("["..shell.dir().."] ")
  112.         elseif setting.main["CMD Count"] == true then
  113.                 term.write("("..#prevTyped..")["..shell.dir().."] ")
  114.         end -- Command Count setting
  115.        
  116.         term.setTextColor(setting.main["Text Color"])
  117.         input = read()
  118.        
  119.         if string.sub(input,1,1) == "@" then
  120.                 customCode = true
  121.         else
  122.                 customCode = false
  123.         end
  124.        
  125.         for k,v in pairs(aliasList) do
  126.                 if v == string.sub(input,2) and customCode == true then
  127.                         functionsList[aliasNum[k]]()
  128.                 end
  129.         end
  130.  
  131.         if customCode == false then
  132.                
  133.                 if #input > 0 then
  134.                         table.insert(prevTyped, input)
  135.                 end
  136.                
  137.                 local marked
  138.                
  139.                 for i,v in pairs(blacklist) do
  140.                         if string.sub(input,1,#v) == v then
  141.                                 marked = true
  142.                         end
  143.                 end
  144.        
  145.                 if marked ~= true then
  146.                         term.setTextColor(colors.white)
  147.                         shell.run(input)
  148.                 else
  149.                         term.setTextColor(colors.red)
  150.                         print("Access Denied")
  151.                 end
  152.                
  153.         end
  154. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement