aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorAlexander Schlögl2022-12-12 02:06:24 +0000
committerGitHub2022-12-12 02:06:24 +0000
commit0b960216433956503e9e6fe5220523eb1970eaee (patch)
treef37c5c10e97e62d04ce9e5b4e415b7b8289db490 /helix-term/src
parentd5ab974d38fd5565a63c8d7c35967c77c0e434d0 (diff)
Add `:pipe-to` typable command that ignores shell output (#4931)
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands/typed.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 03fcaa55..2119a48d 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -1741,13 +1741,30 @@ fn insert_output(
Ok(())
}
+fn pipe_to(
+ cx: &mut compositor::Context,
+ args: &[Cow<str>],
+ event: PromptEvent,
+) -> anyhow::Result<()> {
+ pipe_impl(cx, args, event, &ShellBehavior::Ignore)
+}
+
fn pipe(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) -> anyhow::Result<()> {
+ pipe_impl(cx, args, event, &ShellBehavior::Replace)
+}
+
+fn pipe_impl(
+ cx: &mut compositor::Context,
+ args: &[Cow<str>],
+ event: PromptEvent,
+ behavior: &ShellBehavior,
+) -> anyhow::Result<()> {
if event != PromptEvent::Validate {
return Ok(());
}
ensure!(!args.is_empty(), "Shell command required");
- shell(cx, &args.join(" "), &ShellBehavior::Replace);
+ shell(cx, &args.join(" "), behavior);
Ok(())
}
@@ -2293,6 +2310,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
completer: None,
},
TypableCommand {
+ name: "pipe-to",
+ aliases: &[],
+ doc: "Pipe each selection to the shell command, ignoring output.",
+ fun: pipe_to,
+ completer: None,
+ },
+ TypableCommand {
name: "run-shell-command",
aliases: &["sh"],
doc: "Run a shell command",