mirror of
https://github.com/wez/wezterm.git
synced 2024-11-22 22:42:48 +03:00
add wezterm cli spawn --new-window
flag
refs: https://github.com/wez/wezterm/issues/887
This commit is contained in:
parent
618f77f2c6
commit
e3fdef7fb4
@ -41,6 +41,7 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
* Fixed: don't keep the window alive after running `something & disown ; exit` [#839](https://github.com/wez/wezterm/issues/839)
|
||||
* Improved: we now draw sextant glyphs from the Unicode Symbols for Legacy Computing block (1FB00) when `custom_block_glyphs` is enabled.
|
||||
* Changed: `COLORTERM=truecolor` is now set in the environment. [#875](https://github.com/wez/wezterm/issues/875)
|
||||
* New: `wezterm cli spawn --new-window` flag for creating a new window via the CLI [#887](https://github.com/wez/wezterm/issues/887)
|
||||
|
||||
### 20210502-154244-3f7122cb
|
||||
|
||||
|
@ -153,6 +153,10 @@ Outputs the pane-id for the newly created pane on success"
|
||||
#[structopt(long = "window-id")]
|
||||
window_id: Option<WindowId>,
|
||||
|
||||
/// Spawn into a new window, rather than a new tab
|
||||
#[structopt(long = "new-window", conflicts_with = "window_id")]
|
||||
new_window: bool,
|
||||
|
||||
/// Specify the current working directory for the initially
|
||||
/// spawned program
|
||||
#[structopt(long = "cwd", parse(from_os_str))]
|
||||
@ -459,41 +463,46 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow:
|
||||
pane_id,
|
||||
domain_name,
|
||||
window_id,
|
||||
new_window,
|
||||
} => {
|
||||
let window_id = match window_id {
|
||||
Some(w) => Some(w),
|
||||
None => {
|
||||
let pane_id: PaneId = match pane_id {
|
||||
Some(p) => p,
|
||||
None => std::env::var("WEZTERM_PANE")
|
||||
.map_err(|_| {
|
||||
anyhow!(
|
||||
"--pane-id was not specified and $WEZTERM_PANE
|
||||
let window_id = if new_window {
|
||||
None
|
||||
} else {
|
||||
match window_id {
|
||||
Some(w) => Some(w),
|
||||
None => {
|
||||
let pane_id: PaneId = match pane_id {
|
||||
Some(p) => p,
|
||||
None => std::env::var("WEZTERM_PANE")
|
||||
.map_err(|_| {
|
||||
anyhow!(
|
||||
"--pane-id was not specified and $WEZTERM_PANE
|
||||
is not set in the environment"
|
||||
)
|
||||
})?
|
||||
.parse()?,
|
||||
};
|
||||
)
|
||||
})?
|
||||
.parse()?,
|
||||
};
|
||||
|
||||
let panes = client.list_panes().await?;
|
||||
let mut window_id = None;
|
||||
'outer: for tabroot in panes.tabs {
|
||||
let mut cursor = tabroot.into_tree().cursor();
|
||||
let panes = client.list_panes().await?;
|
||||
let mut window_id = None;
|
||||
'outer: for tabroot in panes.tabs {
|
||||
let mut cursor = tabroot.into_tree().cursor();
|
||||
|
||||
loop {
|
||||
if let Some(entry) = cursor.leaf_mut() {
|
||||
if entry.pane_id == pane_id {
|
||||
window_id.replace(entry.window_id);
|
||||
break 'outer;
|
||||
loop {
|
||||
if let Some(entry) = cursor.leaf_mut() {
|
||||
if entry.pane_id == pane_id {
|
||||
window_id.replace(entry.window_id);
|
||||
break 'outer;
|
||||
}
|
||||
}
|
||||
match cursor.preorder_next() {
|
||||
Ok(c) => cursor = c,
|
||||
Err(_) => break,
|
||||
}
|
||||
}
|
||||
match cursor.preorder_next() {
|
||||
Ok(c) => cursor = c,
|
||||
Err(_) => break,
|
||||
}
|
||||
}
|
||||
window_id
|
||||
}
|
||||
window_id
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user