Add shell insert commands to typable and config (#2589)

* Add shell insert commands to typable and config

* generate docs

Co-authored-by: Dean Revell <revell@gmail.com>
This commit is contained in:
Termina94 2022-06-05 11:52:41 +01:00 committed by GitHub
parent f92a25a856
commit f1ae496860
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

View File

@ -64,5 +64,7 @@
| `:config-reload` | Refreshes helix's config. |
| `:config-open` | Open the helix config.toml file. |
| `:log-open` | Open the helix log file. |
| `:insert-output` | Run shell command, inserting output after each selection. |
| `:append-output` | Run shell command, appending output after each selection. |
| `:pipe` | Pipe each selection to the shell command. |
| `:run-shell-command`, `:sh` | Run a shell command |

View File

@ -1172,6 +1172,26 @@ fn refresh_config(
Ok(())
}
fn append_output(
cx: &mut compositor::Context,
args: &[Cow<str>],
_event: PromptEvent,
) -> anyhow::Result<()> {
ensure!(!args.is_empty(), "Shell command required");
shell(cx, &args.join(" "), &ShellBehavior::Append);
Ok(())
}
fn insert_output(
cx: &mut compositor::Context,
args: &[Cow<str>],
_event: PromptEvent,
) -> anyhow::Result<()> {
ensure!(!args.is_empty(), "Shell command required");
shell(cx, &args.join(" "), &ShellBehavior::Insert);
Ok(())
}
fn pipe(
cx: &mut compositor::Context,
args: &[Cow<str>],
@ -1671,6 +1691,20 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
fun: open_log,
completer: None,
},
TypableCommand {
name: "insert-output",
aliases: &[],
doc: "Run shell command, inserting output after each selection.",
fun: insert_output,
completer: None,
},
TypableCommand {
name: "append-output",
aliases: &[],
doc: "Run shell command, appending output after each selection.",
fun: append_output,
completer: None,
},
TypableCommand {
name: "pipe",
aliases: &[],