mirror of
https://github.com/wez/wezterm.git
synced 2024-11-22 22:42:48 +03:00
add clean_exit_codes config
refs: https://github.com/wez/wezterm/issues/1889
This commit is contained in:
parent
ee2bce5138
commit
f7b34438ed
@ -128,6 +128,9 @@ pub struct Config {
|
||||
#[serde(default)]
|
||||
pub exit_behavior: ExitBehavior,
|
||||
|
||||
#[serde(default = "default_clean_exits")]
|
||||
pub clean_exit_codes: Vec<u32>,
|
||||
|
||||
/// Specifies a map of environment variables that should be set
|
||||
/// when spawning commands in the local domain.
|
||||
/// This is not used when working with remote domains.
|
||||
@ -1270,6 +1273,10 @@ fn default_prefer_egl() -> bool {
|
||||
!cfg!(windows)
|
||||
}
|
||||
|
||||
fn default_clean_exits() -> Vec<u32> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn default_inactive_pane_hsb() -> HsbTransform {
|
||||
HsbTransform {
|
||||
brightness: 0.8,
|
||||
|
@ -20,6 +20,7 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
* Specifying a domain name in a [SpawnCommand](config/lua/SpawnCommand.md) will cause that domain to be attached if it is in the detached state. This is useful when combined with [SwitchToWorkspace](config/lua/keyassignment/SwitchToWorkspace.md).
|
||||
* X11: wezterm now sets `_NET_WM_NAME` in addition to `WM_NAME` for clients that don't know how to fallback
|
||||
* [treat_east_asian_ambiguous_width_as_wide](config/lua/config/treat_east_asian_ambiguous_width_as_wide.md) for control how ambiguous width characters are resolved. [#1888](https://github.com/wez/wezterm/issues/1888)
|
||||
* [clean_exit_codes](config/lua/config/clean_exit_codes.md) config to fine tune [exit_behavior](config/lua/config/exit_behavior.md) [#1889](https://github.com/wez/wezterm/issues/1889)
|
||||
|
||||
#### Changed
|
||||
* Debian packages now register wezterm as an alternative for `x-terminal-emulator`. Thanks to [@xpufx](https://github.com/xpufx)! [#1883](https://github.com/wez/wezterm/pull/1883)
|
||||
|
21
docs/config/lua/config/clean_exit_codes.md
Normal file
21
docs/config/lua/config/clean_exit_codes.md
Normal file
@ -0,0 +1,21 @@
|
||||
## `clean_exit_codes = { 0 }`
|
||||
|
||||
*Since: nightly builds only*
|
||||
|
||||
Defines the set of exit codes that are considered to be a "clean" exit by
|
||||
[exit_behavior](exit_behavior.md) when the program running in the terminal
|
||||
completes.
|
||||
|
||||
Acceptable values are an array of integer exit codes that you wish to treat
|
||||
as successful.
|
||||
|
||||
For example, if you often `CTRL-C` a program and then `CTRL-D`, bash will
|
||||
typically exit with status `130` to indicate that a program was terminated
|
||||
with SIGINT, but that bash itself wasn't. In that situation you may wish
|
||||
to set this config to treat `130` as OK:
|
||||
|
||||
```lua
|
||||
return {
|
||||
clean_exit_codes = {130},
|
||||
}
|
||||
```
|
@ -30,3 +30,5 @@ exit
|
||||
With the default `exit_behavior="CloseOnCleanExit"` setting, that will cause
|
||||
the pane to remain open.
|
||||
|
||||
See also: [clean_exit_codes](clean_exit_codes.md) for fine tuning what is
|
||||
considered to be a clean exit status.
|
||||
|
@ -159,8 +159,16 @@ impl Pane for LocalPane {
|
||||
Err(TryRecvError::Empty) => None,
|
||||
_ => Some(ExitStatus::with_exit_code(1)),
|
||||
};
|
||||
|
||||
if let Some(status) = status {
|
||||
match (configuration().exit_behavior, status.success(), killed) {
|
||||
let success = match status.success() {
|
||||
true => true,
|
||||
false => configuration()
|
||||
.clean_exit_codes
|
||||
.contains(&status.exit_code()),
|
||||
};
|
||||
|
||||
match (configuration().exit_behavior, success, killed) {
|
||||
(ExitBehavior::Close, _, _) => *proc = ProcessState::Dead,
|
||||
(ExitBehavior::CloseOnCleanExit, false, false) => {
|
||||
notify = Some(format!(
|
||||
|
@ -181,6 +181,11 @@ impl ExitStatus {
|
||||
Some(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the exit code that this ExitStatus was constructed with
|
||||
pub fn exit_code(&self) -> u32 {
|
||||
self.code
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::process::ExitStatus> for ExitStatus {
|
||||
|
Loading…
Reference in New Issue
Block a user