forked from zyedidia/micro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugin: pipe (selection throught command)
- Loading branch information
1 parent
a74c29c
commit c2b573a
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |