mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-22 15:53:29 +01:00
Add simple 'directories' plugin
This commit is contained in:
parent
040242c9be
commit
446b9181e6
17
plugins/directories.lua
Normal file
17
plugins/directories.lua
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
-- 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
|
Loading…
Reference in New Issue
Block a user