From 2eca2901f31083af85ffd6f299c64ad80a8bfaf5 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 17 Apr 2022 05:03:47 +0200 Subject: Pipe typable command (#1972) Co-authored-by: DeviousStoat --- helix-term/src/commands/typed.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'helix-term/src/commands') diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index d158388f..9a5298bb 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -1067,6 +1067,16 @@ fn refresh_config( Ok(()) } +fn pipe( + cx: &mut compositor::Context, + args: &[Cow], + _event: PromptEvent, +) -> anyhow::Result<()> { + ensure!(!args.is_empty(), "Shell command required"); + shell(cx, &args.join(" "), &ShellBehavior::Replace); + Ok(()) +} + pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ TypableCommand { name: "quit", @@ -1495,6 +1505,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ fun: open_config, completer: None, }, + TypableCommand { + name: "pipe", + aliases: &[], + doc: "Pipe each selection to the shell command.", + fun: pipe, + completer: None, + }, ]; pub static TYPABLE_COMMAND_MAP: Lazy> = -- cgit v1.2.3-70-g09d2