1
0
mirror of https://github.com/sharkdp/bat.git synced 2024-10-05 18:31:06 +01:00
bat/plugins/directories.lua
2022-05-29 21:04:47 +02:00

18 lines
408 B
Lua

-- https://stackoverflow.com/a/3254007/704831
function is_dir(path)
local f = io.open(path, "r")
local ok, err, code = f:read(1)
f:close()
return code == 21
end
function preprocess(path)
if is_dir(path) then
tmpfile = os.tmpname()
os.execute("ls -alh --color=always '" .. path .. "' > '" .. tmpfile .. "'")
return tmpfile
else
return path
end
end