1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 15:04:36 +03:00

wezterm cli: add send-text --no-paste option

refs: https://github.com/wez/wezterm/issues/888#issuecomment-1123462175
This commit is contained in:
Wez Furlong 2022-05-25 07:45:34 -07:00
parent 8cce462780
commit 385f3c99d3
2 changed files with 24 additions and 7 deletions

View File

@ -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

View File

@ -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<PaneId>,
/// 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<String>,
},
@ -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,