Skip to content

Commit

Permalink
plugin: pipe (selection throught command)
Browse files Browse the repository at this point in the history
  • Loading branch information
shkschneider committed Jan 28, 2024
1 parent a74c29c commit c2b573a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions runtime/plugins/pipe/pipe.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
AUTHOR = "shkschneider/macro"
NAME = "pipe"
VERSION = "1.1.0"

local micro = import("micro")
local config = import("micro/config")
local buffer = import("micro/buffer")
local util = import("micro/util")
local strings = import("strings")

function Pipe(bp, args)
if not bp.Cursor:HasSelection() then return micro.InfoBar():Error("No selection") end
local selection = util.String(bp.Cursor:GetSelection())
micro.InfoBar():Prompt("Pipe: ", "", "Pipe", nil, function (out, cancelled)
if cancelled then return end
command = strings.TrimSpace(out)
bp:HandleCommand("textfilter " .. out)
micro.InfoBar():Message(out)
end)
end

function init()
config.MakeCommand("pipe", Pipe, config.NoComplete)
config.TryBindKey("Ctrl-p", "command:pipe", false)
end

0 comments on commit c2b573a

Please sign in to comment.