rungholt

lsd

Mar 3rd, 2021
867
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tArgs = { ... }
  2.  
  3. -- Get all the files in the directory
  4. local sDir = shell.dir()
  5. if tArgs[1] ~= nil then
  6.     sDir = shell.resolve(tArgs[1])
  7. end
  8.  
  9. if not fs.isDir(sDir) then
  10.     printError("Not a directory")
  11.     return
  12. end
  13.  
  14. -- Sort into dirs/files, and calculate column count
  15. local tAll = fs.list(sDir)
  16. local tFiles = {}
  17. local tDirs = {}
  18.  
  19. local bShowHidden = settings.get("list.show_hidden")
  20. for _, sItem in pairs(tAll) do
  21.     if bShowHidden or string.sub(sItem, 1, 1) ~= "." then
  22.         local sPath = fs.combine(sDir, sItem)
  23.         if fs.isDir(sPath) then
  24.             table.insert(tDirs, sItem)
  25.         end
  26.     end
  27. end
  28. table.sort(tDirs)
  29. table.sort(tFiles)
  30.  
  31. if term.isColour() then
  32.     textutils.pagedTabulate(colors.green, tDirs, colors.white, tFiles)
  33. else
  34.     textutils.pagedTabulate(tDirs, tFiles)
  35. end
  36.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×