on master help sign in
Add shell insert commands to typable and config (#2589)
f1ae496Termina94
book/src/generated/typable-cmd.md+2
@@ -64,5 +64,7 @@
64| `:config-reload` | Refreshes helix's config. |
64| `:config-reload` | Refreshes helix's config. |
65| `:config-open` | Open the helix config.toml file. |
65| `:config-open` | Open the helix config.toml file. |
66| `:log-open` | Open the helix log file. |
66| `:log-open` | Open the helix log file. |
67+| `:insert-output` | Run shell command, inserting output after each selection. |
68+| `:append-output` | Run shell command, appending output after each selection. |
67| `:pipe` | Pipe each selection to the shell command. |
69| `:pipe` | Pipe each selection to the shell command. |
68| `:run-shell-command`, `:sh` | Run a shell command |
70| `:run-shell-command`, `:sh` | Run a shell command |
helix-term/src/commands/typed.rs+34
@@ -1172,6 +1172,26 @@ fn refresh_config(
1172 Ok(())
1172 Ok(())
1173}
1173}
1174
1174
1175+fn append_output(
1176+ cx: &mut compositor::Context,
1177+ args: &[Cow<str>],
1178+ _event: PromptEvent,
1179+) -> anyhow::Result<()> {
1180+ ensure!(!args.is_empty(), "Shell command required");
1181+ shell(cx, &args.join(" "), &ShellBehavior::Append);
1182+ Ok(())
1183+}
1184+
1185+fn insert_output(
1186+ cx: &mut compositor::Context,
1187+ args: &[Cow<str>],
1188+ _event: PromptEvent,
1189+) -> anyhow::Result<()> {
1190+ ensure!(!args.is_empty(), "Shell command required");
1191+ shell(cx, &args.join(" "), &ShellBehavior::Insert);
1192+ Ok(())
1193+}
1194+
1175fn pipe(
1195fn pipe(
1176 cx: &mut compositor::Context,
1196 cx: &mut compositor::Context,
1177 args: &[Cow<str>],
1197 args: &[Cow<str>],
@@ -1671,6 +1691,20 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
1671 fun: open_log,
1691 fun: open_log,
1672 completer: None,
1692 completer: None,
1673 },
1693 },
1694+ TypableCommand {
1695+ name: "insert-output",
1696+ aliases: &[],
1697+ doc: "Run shell command, inserting output after each selection.",
1698+ fun: insert_output,
1699+ completer: None,
1700+ },
1701+ TypableCommand {
1702+ name: "append-output",
1703+ aliases: &[],
1704+ doc: "Run shell command, appending output after each selection.",
1705+ fun: append_output,
1706+ completer: None,
1707+ },
1674 TypableCommand {
1708 TypableCommand {
1675 name: "pipe",
1709 name: "pipe",
1676 aliases: &[],
1710 aliases: &[],