draft // Custom LS Script
// Usage: ls [directory]
// Fixed issue with directory not finding anything else other than current_path
cyan = "<color=#0EC6FE>"
orange = "<color=#FF8D08>"
purple = "<color=#AC0BC3>"
gold = "<color=#E0E10C>"
green = "<color=#2CC018>"
cend = "</color>"
computer = get_shell.host_computer
listDirectory = function(directoryPath)
folder = computer.File(directoryPath)
if folder == null then
print("ls: No such file or directory")
return
end if
if not folder.has_permission("r") then
print("ls: permission denied")
return
end if
subFiles = folder.get_folders + folder.get_files
folderOutput = ""
fileOutput = ""
for subFile in subFiles
nameFile = subFile.name
permission = subFile.permissions
owner = subFile.owner
size = subFile.size
group = subFile.group
if nameFile.indexOf(".") == 0 then
continue // Skip hidden files and folders
end if
if subFile.is_folder then
folderLine = cyan + nameFile + cend + " " + orange + permission + cend + " " + "<color=red>" + owner + "</color>" + " " + "<color=red>" + group + "</color>" + " " + size
folderOutput = folderOutput + folderLine + "\n"
else
fileLine = cyan + nameFile + cend + " " + orange + permission + cend + " " + "<color=red>" + owner + "</color>" + " " + "<color=red>" + group + "</color>" + " " + size
fileOutput = fileOutput + fileLine + "\n"
end if
end for
if folderOutput != "" then
print("FOLDERS: PERMISSION OWNER GROUP SIZE")
print("====================================================")
print(folderOutput)
print("====================================================")
end if
if fileOutput != "" then
print("FILES: PERMISSION OWNER GROUP SIZE")
print("====================================================")
print(fileOutput)
print("====================================================")
end if
end function
params = params()
if params.len == 0 then
directoryPath = current_path
else
directoryPath = params[0]
end if
listDirectory(directoryPath)
content