new exit_behavior_messaging option
Controls the message that is shown when holding a pane open after a process has completed. refs: #3423
This commit is contained in:
4 files changed
+166
-18
No files matched your search
@@ -203,6 +203,9 @@ pub struct Config {
|
||||
#[dynamic(default)]
|
||||
pub exit_behavior: ExitBehavior,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub exit_behavior_messaging: ExitBehaviorMessaging,
|
||||
|
||||
#[dynamic(default = "default_clean_exits")]
|
||||
pub clean_exit_codes: Vec<u32>,
|
||||
|
||||
@@ -1870,6 +1873,15 @@ pub enum ExitBehavior {
|
||||
Hold,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromDynamic, ToDynamic, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum ExitBehaviorMessaging {
|
||||
#[default]
|
||||
Verbose,
|
||||
Brief,
|
||||
Terse,
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromDynamic, ToDynamic, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum DroppedFileQuoting {
|
||||
/// No quoting is performed, the file name is passed through as-is
|
||||
|
||||
@@ -53,6 +53,7 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
customize the appearance of
|
||||
[CharSelect](config/lua/keyassignment/CharSelect.md) mode. Thanks to @junnplus! #3703
|
||||
* Horizontal mouse wheel events are now passed through to the terminal. Thanks to @calops! #3856
|
||||
* [exit_behavior_messaging](config/lua/config/exit_behavior_messaging.md) option to control output when holding a pane open after a process completes. #3423
|
||||
|
||||
#### Fixed
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
---
|
||||
tags:
|
||||
- exit_behavior
|
||||
---
|
||||
## `exit_behavior_messaging = "Verbose"`
|
||||
|
||||
{{since('nightly')}}
|
||||
|
||||
Controls how wezterm indicates the exit status of the spawned process
|
||||
in a pane when it terminates.
|
||||
|
||||
If [exit_behavior](exit_behavior.md) is set to keep the pane open after
|
||||
the process has completed, wezterm will display a message to let you
|
||||
know that it has finished.
|
||||
|
||||
This option controls that message. It can have one of the following
|
||||
values:
|
||||
|
||||
* `"Verbose"` - Shows 2-3 lines of explanation, including the process name, its exit status and a link to the [exit_behavior](exit_behavior.md) documentation.
|
||||
* `"Brief"` - Like `"Verbose"`, but the link to the documentation is not included.
|
||||
* `"Terse"` - A very short indication of the exit status is shown in square brackets.
|
||||
* `"None"` - No message is shown.
|
||||
|
||||
In earlier versions of wezterm, this was not configurable and behaved equivalently
|
||||
to the `"Verbose"` setting.
|
||||
|
||||
## Example of a failing process with Verbose messaging
|
||||
|
||||
```console
|
||||
$ wezterm -n --config 'default_prog={"false"}' \
|
||||
--config 'exit_behavior="Hold"' \
|
||||
--config 'exit_behavior_messaging="Verbose"'
|
||||
```
|
||||
|
||||
Produces:
|
||||
|
||||
```
|
||||
⚠️ Process "false" in domain "local" didn't exit cleanly
|
||||
Exited with code 1
|
||||
This message is shown because exit_behavior="Hold"
|
||||
```
|
||||
|
||||
## Example of a failing process with Brief messaging
|
||||
|
||||
```console
|
||||
$ wezterm -n --config 'default_prog={"false"}' \
|
||||
--config 'exit_behavior="Hold"' \
|
||||
--config 'exit_behavior_messaging="Brief"'
|
||||
```
|
||||
|
||||
Produces:
|
||||
|
||||
```
|
||||
⚠️ Process "false" in domain "local" didn't exit cleanly
|
||||
Exited with code 1
|
||||
```
|
||||
|
||||
## Example of a failing process with Terse messaging
|
||||
|
||||
```console
|
||||
$ wezterm -n --config 'default_prog={"false"}' \
|
||||
--config 'exit_behavior="Hold"' \
|
||||
--config 'exit_behavior_messaging="Terse"'
|
||||
```
|
||||
|
||||
Produces:
|
||||
|
||||
```
|
||||
[Exited with code 1]
|
||||
```
|
||||
|
||||
## Example of a successful process with Verbose messaging
|
||||
|
||||
```console
|
||||
$ wezterm -n --config 'default_prog={"true"}' \
|
||||
--config 'exit_behavior="Hold"' \
|
||||
--config 'exit_behavior_messaging="Verbose"'
|
||||
```
|
||||
|
||||
Produces:
|
||||
|
||||
```
|
||||
👍 Process "true" in domain "local" completed.
|
||||
This message is shown because exit_behavior="Hold"
|
||||
```
|
||||
|
||||
## Example of a successful process with Brief messaging
|
||||
|
||||
```console
|
||||
$ wezterm -n --config 'default_prog={"true"}' \
|
||||
--config 'exit_behavior="Hold"' \
|
||||
--config 'exit_behavior_messaging="Brief"'
|
||||
```
|
||||
|
||||
Produces:
|
||||
|
||||
```
|
||||
👍 Process "true" in domain "local" completed.
|
||||
```
|
||||
|
||||
## Example of a successful process with Terse messaging
|
||||
|
||||
```console
|
||||
$ wezterm -n --config 'default_prog={"true"}' \
|
||||
--config 'exit_behavior="Hold"' \
|
||||
--config 'exit_behavior_messaging="Terse"'
|
||||
```
|
||||
|
||||
Produces:
|
||||
|
||||
```
|
||||
[done]
|
||||
```
|
||||
+40
-18
@@ -9,7 +9,7 @@ use crate::{Domain, Mux, MuxNotification};
|
||||
use anyhow::Error;
|
||||
use async_trait::async_trait;
|
||||
use config::keyassignment::ScrollbackEraseMode;
|
||||
use config::{configuration, ExitBehavior};
|
||||
use config::{configuration, ExitBehavior, ExitBehaviorMessaging};
|
||||
use fancy_regex::Regex;
|
||||
use parking_lot::{MappedMutexGuard, Mutex, MutexGuard};
|
||||
use portable_pty::{Child, ChildKiller, ExitStatus, MasterPty, PtySize};
|
||||
@@ -260,13 +260,17 @@ impl Pane for LocalPane {
|
||||
|
||||
fn is_dead(&self) -> bool {
|
||||
let mut proc = self.process.lock();
|
||||
let mut notify = None;
|
||||
|
||||
const EXIT_BEHAVIOR: &str = "This message is shown because \
|
||||
\x1b]8;;https://wezfurlong.org/wezterm/\
|
||||
config/lua/config/exit_behavior.html\
|
||||
\x1b\\exit_behavior\x1b]8;;\x1b\\";
|
||||
|
||||
let mut terse = String::new();
|
||||
let mut brief = String::new();
|
||||
let mut trailer = String::new();
|
||||
let cmd = &self.command_description;
|
||||
|
||||
match &mut *proc {
|
||||
ProcessState::Running {
|
||||
child_waiter,
|
||||
@@ -295,28 +299,22 @@ impl Pane for LocalPane {
|
||||
) {
|
||||
(ExitBehavior::Close, _, _) => *proc = ProcessState::Dead,
|
||||
(ExitBehavior::CloseOnCleanExit, false, _) => {
|
||||
notify = Some(format!(
|
||||
"\r\n⚠️ Process {} didn't exit cleanly\r\n{}.\r\n{}=\"CloseOnCleanExit\"\r\n",
|
||||
self.command_description,
|
||||
status,
|
||||
EXIT_BEHAVIOR
|
||||
));
|
||||
brief = format!("⚠️ Process {cmd} didn't exit cleanly");
|
||||
terse = format!("{status}.");
|
||||
trailer = format!("{EXIT_BEHAVIOR}=\"CloseOnCleanExit\"");
|
||||
|
||||
*proc = ProcessState::DeadPendingClose { killed: false }
|
||||
}
|
||||
(ExitBehavior::CloseOnCleanExit, ..) => *proc = ProcessState::Dead,
|
||||
(ExitBehavior::Hold, success, false) => {
|
||||
trailer = format!("{EXIT_BEHAVIOR}=\"Hold\"");
|
||||
|
||||
if success {
|
||||
notify = Some(format!(
|
||||
"\r\n👍 Process {} completed.\r\n{}=\"Hold\"\r\n",
|
||||
self.command_description, EXIT_BEHAVIOR
|
||||
));
|
||||
brief = format!("👍 Process {cmd} completed.");
|
||||
terse = "done".to_string();
|
||||
} else {
|
||||
notify = Some(format!(
|
||||
"\r\n⚠️ Process {} didn't exit cleanly\r\n{}.\r\n{}=\"Hold\"\r\n",
|
||||
self.command_description,
|
||||
status,
|
||||
EXIT_BEHAVIOR
|
||||
));
|
||||
brief = format!("⚠️ Process {cmd} didn't exit cleanly");
|
||||
terse = format!("{status}");
|
||||
}
|
||||
*proc = ProcessState::DeadPendingClose { killed: false }
|
||||
}
|
||||
@@ -334,6 +332,30 @@ impl Pane for LocalPane {
|
||||
ProcessState::Dead => {}
|
||||
}
|
||||
|
||||
let mut notify = None;
|
||||
if !terse.is_empty() {
|
||||
match configuration().exit_behavior_messaging {
|
||||
ExitBehaviorMessaging::Verbose => {
|
||||
if terse == "done" {
|
||||
notify = Some(format!("\r\n{brief}\r\n{trailer}"));
|
||||
} else {
|
||||
notify = Some(format!("\r\n{brief}\r\n{terse}\r\n{trailer}"));
|
||||
}
|
||||
}
|
||||
ExitBehaviorMessaging::Brief => {
|
||||
if terse == "done" {
|
||||
notify = Some(format!("\r\n{brief}"));
|
||||
} else {
|
||||
notify = Some(format!("\r\n{brief}\r\n{terse}"));
|
||||
}
|
||||
}
|
||||
ExitBehaviorMessaging::Terse => {
|
||||
notify = Some(format!("\r\n[{terse}]"));
|
||||
}
|
||||
ExitBehaviorMessaging::None => {}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(notify) = notify {
|
||||
emit_output_for_pane(self.pane_id, ¬ify);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user