Update awesome-hacks.md

pull/481/head
Arijit Basu 2 years ago committed by GitHub
parent fba1c2d0d6
commit 3eabbd4ed6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -384,6 +384,84 @@ imv-msg "$IMV_PID" quit
</details>
### Text preview pane
Preview text files in a native xplr pane (should be fast enough).
<details>
<summary>Expand for details</summary>
- Author: [@sayanarijit][8]
- Requires: none
- Tested on: Linux
```lua
local function stat(node)
return node.mime_essence
end
local function read(path, lines)
local out = ""
local p = io.open(path)
if p == nil then
return stat(path)
end
local i = 0
for line in p:lines() do
out = out .. line .. "\n"
if i == lines then
break
end
i = i + 1
end
p:close()
return out
end
xplr.config.layouts.builtin.default = {
Horizontal = {
config = {
constraints = {
{ Percentage = 60 },
{ Percentage = 40 },
},
},
splits = {
"Table",
{
CustomContent = {
title = "preview",
body = { DynamicParagraph = { render = "custom.render_layout" } },
},
},
},
},
}
xplr.fn.custom.render_layout = function(ctx)
local n = ctx.app.focused_node
if n.canonical then
n = n.canonical
end
if n then
if n.is_file and not n.is_symlink then
return read(n.absolute_path, ctx.layout_size.height)
else
return stat(n)
end
else
return ""
end
end
```
</details>
## Also See:
- [Awesome Plugins][15]

Loading…
Cancel
Save