From 385f3c99d3b2311fde1ed494d0d3d327ebdca28b Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 25 May 2022 07:45:34 -0700 Subject: [PATCH] wezterm cli: add send-text --no-paste option refs: https://github.com/wez/wezterm/issues/888#issuecomment-1123462175 --- docs/changelog.md | 2 +- wezterm/src/main.rs | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 779e1e760..466985ada 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -38,7 +38,7 @@ As features stabilize some brief notes about them will accumulate here. * [SplitPane](config/lua/keyassignment/SplitPane.md) key assignment that allows specifying the size and location of the split, as well as top-level (full width/height) splits. `wezterm cli split-pane --help` shows equivalent options you can use from the cli. [#578](https://github.com/wez/wezterm/issues/578) * [ime_preedit_rendering](config/lua/config/ime_preedit_rendering.md) option to choose whether to use the builtin or the system IME preedit rendering mode. Thanks to [@kumattau](https://github.com/kumattau)! [#2006](https://github.com/wez/wezterm/pull/2006) * [wezterm.strftime_utc](config/lua/wezterm/strftime_utc.md) for manipulating times in UTC rather than the local timezone - +* `wezterm cli send-text --no-paste` option to send text to a pain without wrapping it as a bracketed paste #### Updated * Bundled harfbuzz to 4.3.0 diff --git a/wezterm/src/main.rs b/wezterm/src/main.rs index e9babef0a..d55c31164 100644 --- a/wezterm/src/main.rs +++ b/wezterm/src/main.rs @@ -266,14 +266,18 @@ Outputs the pane-id for the newly created pane on success" /// Send text to a pane as though it were pasted. /// If bracketed paste mode is enabled in the pane, then the /// text will be sent as a bracketed paste. - #[structopt(name = "send-text")] + #[structopt(name = "send-text", rename_all = "kebab")] SendText { /// Specify the target pane. /// The default is to use the current pane based on the /// environment variable WEZTERM_PANE. - #[structopt(long = "pane-id")] + #[structopt(long)] pane_id: Option, + /// Send the text directly, rather than as a bracketed paste. + #[structopt(long)] + no_paste: bool, + /// The text to send. If omitted, will read the text from stdin. text: Option, }, @@ -825,7 +829,11 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow: log::debug!("{:?}", spawned); println!("{}", spawned.pane_id); } - CliSubCommand::SendText { pane_id, text } => { + CliSubCommand::SendText { + pane_id, + text, + no_paste, + } => { let pane_id = resolve_pane_id(&client, pane_id).await?; let data = match text { @@ -839,9 +847,18 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow: } }; - client - .send_paste(codec::SendPaste { pane_id, data }) - .await?; + if no_paste { + client + .write_to_pane(codec::WriteToPane { + pane_id, + data: data.as_bytes().to_vec(), + }) + .await?; + } else { + client + .send_paste(codec::SendPaste { pane_id, data }) + .await?; + } } CliSubCommand::SpawnCommand { cwd,